fix(keyboard): stabilize Flow startup under memory pressure
Delay competing Rime work, add extension memory telemetry and stress coverage, and refresh the 1.8 release assets and metadata for build 79.
This commit is contained in:
@@ -9,12 +9,22 @@ import Foundation
|
||||
import Darwin
|
||||
|
||||
public enum OSGDiag {
|
||||
public struct MemorySnapshot: Sendable, Equatable {
|
||||
public let rssMB: Double
|
||||
public let physFootprintMB: Double
|
||||
|
||||
public init(rssMB: Double, physFootprintMB: Double) {
|
||||
self.rssMB = rssMB
|
||||
self.physFootprintMB = physFootprintMB
|
||||
}
|
||||
}
|
||||
|
||||
/// Prefix every line for easy Console search: `OSGDiag`
|
||||
public static func log(_ message: String, category: String = "diag") {
|
||||
let line = "[OSGDiag/\(category)] \(message)"
|
||||
NSLog("%@", line)
|
||||
switch category {
|
||||
case "keyboardExt", "boot":
|
||||
case "keyboardExt", "boot", "memory":
|
||||
OSGLog.keyboardExt.info("\(line, privacy: .public)")
|
||||
case "flow", "asr":
|
||||
OSGLog.flow.info("\(line, privacy: .public)")
|
||||
@@ -40,7 +50,31 @@ public enum OSGDiag {
|
||||
return Double(info.resident_size) / 1_048_576.0
|
||||
}
|
||||
|
||||
/// Physical footprint in MiB. iOS jetsam tracks this more closely than RSS.
|
||||
public static func physFootprintMB() -> Double {
|
||||
var info = task_vm_info_data_t()
|
||||
var count = mach_msg_type_number_t(
|
||||
MemoryLayout<task_vm_info_data_t>.size / MemoryLayout<natural_t>.size
|
||||
)
|
||||
let kr = withUnsafeMutablePointer(to: &info) { ptr in
|
||||
ptr.withMemoryRebound(to: integer_t.self, capacity: Int(count)) { rebound in
|
||||
task_info(mach_task_self_, task_flavor_t(TASK_VM_INFO), rebound, &count)
|
||||
}
|
||||
}
|
||||
guard kr == KERN_SUCCESS else { return -1 }
|
||||
return Double(info.phys_footprint) / 1_048_576.0
|
||||
}
|
||||
|
||||
public static func memorySnapshot() -> MemorySnapshot {
|
||||
MemorySnapshot(rssMB: memoryMB(), physFootprintMB: physFootprintMB())
|
||||
}
|
||||
|
||||
public static func memoryTag() -> String {
|
||||
String(format: "rss=%.1fMB", memoryMB())
|
||||
let snapshot = memorySnapshot()
|
||||
return String(
|
||||
format: "rss=%.1fMB foot=%.1fMB",
|
||||
snapshot.rssMB,
|
||||
snapshot.physFootprintMB
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user