import ParcelCore struct BenchmarkCatalogEntry: Codable, Equatable, Sendable { enum Kind: String, Codable, Sendable { case headless, e2e, signpost } enum Status: String, Codable, Sendable { case executable, unsupported } let name: String let kind: Kind let status: Status let iterations: Int let budget: String let reportingOnly: Bool let reason: String? var cpuBudgetNanoseconds: Double? { let count = Int(name.split(separator: "/").last ?? "") if name.hasPrefix("reduce-layout/") { return 200_000 } if name.hasPrefix("snapshot-publish/") { return count == 10 ? 50_000 : count == 50 ? 200_000 : 800_000 } if name.hasPrefix("motion-tick/") { return count == 1 ? 20_000 : count == 10 ? 100_000 : 300_000 } if name.hasPrefix("overlay-update/") { return count == 1 ? 100_000 : count == 10 ? 300_000 : 800_000 } if name.hasPrefix("reduce.focusObservation.") { return 20_000 } if name.hasPrefix("reduce.windowFrameEdited.tick.") || name.hasPrefix("reduce.tileEdgeResized.tick.") { return name.hasSuffix("200") ? 2_000_000 : 500_000 } if name.hasPrefix("layout.arrange.") || name.hasPrefix("layout.edges.columns.") { return 500_000 } switch name { case "input-tap/keydown-hotkey": return 20_000 case "input-tap/keydown-passthrough": return 5_000 case "input-tap/mouse-moved": return 10_000 case "motion-retarget/10": return 150_000 case "overlay-frame/30": return 500_000 case "window-list-read/decode-40": return 100_000 case "window-list-read/decode-200": return 500_000 case "WindowListDecode/200": return 300_000 case "WatchdogBeginEnd": return 50 case "reduce.batch.mixed8.50": return 2_000_000 case "engine.snapshot.publish.1subs", "engine.snapshot.publish.4subs": return 50_000 case "Overlay/HighlightUpdate/10-unchanged": return 50_000 case "Overlay/HighlightUpdate/10-moved": return 300_000 case "Overlay/Consume/50-windows": return 500_000 case "Overlay/ThemeChange/10-windows": return 1_000_000 case "MenuBar/IconRender": return 200_000 case "Chips/Update/unchanged": return 20_000 default: return nil } } } enum BenchmarkCatalog { private static let core: String? = nil private static let motion = "Motion coalescing, per-window rates and allocation fixes are pending; collect actual dispatch/sample counts without gating." private static let platform = "Native event and AX write fast paths are pending. Fake-backend method calls are measured, not inferred AX calls or actor hops." private static let overlay = "Persistent layers, render coalescing and shared palette fixes are pending; layer identity deltas count new reachable layers, not total mallocs." static let entries: [BenchmarkCatalogEntry] = { var values: [BenchmarkCatalogEntry] = [] func headless(_ name: String, _ budget: String, _ reason: String?, iterations: Int = 10) { values.append( BenchmarkCatalogEntry( name: name, kind: .headless, status: .executable, iterations: iterations, budget: budget, reportingOnly: reason != nil, reason: reason)) } func deferred(_ name: String, _ kind: BenchmarkCatalogEntry.Kind, _ budget: String, _ reason: String) { values.append( BenchmarkCatalogEntry( name: name, kind: kind, status: .unsupported, iterations: 0, budget: budget, reportingOnly: true, reason: reason)) } for (variant, budget) in [ ("keydown-hotkey", "20 us"), ("keydown-passthrough", "5 us"), ("mouse-moved", "10 us"), ] { headless( "input-tap/\(variant)", "instructions +3%; release CPU <= \(budget)", "Synthetic CGEvent runs real handlers. Hotkey counts measure press callbacks, not engine enqueues; event-tap scheduling and kernel delivery require live tracing.", iterations: 100) } for count in [10, 50, 200] { for kind in ["window-moved", "window-created", "focus"] { let budget = kind == "focus" ? (count == 10 ? "0.2" : count == 50 ? "1" : "4") : (count == 10 ? "0.5" : count == 50 ? "2" : "8") headless( "ax-notify-to-decision/\(kind)/\(count)", "instructions +3%; release CPU <= \(budget) ms", platform, iterations: 3) } headless( "snapshot-publish/\(count)", "instructions +3%; release CPU <= \(count == 10 ? 50 : count == 50 ? 200 : 800) us", core) for workspaces in [1, 8] { headless( "reduce.focusObservation.\(count)x\(workspaces)ws", "release CPU <= 20 us at 200 windows; linear 50->200 scaling", core) } for variant in ["windowFrameEdited", "tileEdgeResized"] { headless("reduce.\(variant).tick.\(count)", "release CPU <= 0.5 ms at 50; <= 2 ms at 200", core) } } for layout in Layout.allCases { headless("reduce-layout/\(layout.rawValue)/10", "instructions +3%; release CPU <= 0.2 ms", core) } for count in [1, 10, 30] { headless( "motion-tick/\(count)", "instructions +3%; mallocs/tick exact; release CPU/tick <= \(count == 1 ? 20 : count == 10 ? 100 : 300) us", motion) headless( "overlay-update/\(count)", "instructions +3%; release CPU <= \(count == 1 ? 100 : count == 10 ? 300 : 800) us", overlay) } headless("motion-retarget/10", "instructions +3%; release CPU <= 150 us", motion) headless("overlay-frame/30", "instructions +3%; mallocs/frame exact; release CPU <= 500 us", overlay) for count in [40, 200] { headless( "window-list-read/decode-\(count)", "instructions +3%; release CPU <= \(count == 40 ? 100 : 500) us", "Integer decoding optimization pending; sanitized recorded geometry is selected/repeated to scale the corpus, with fixture parsing excluded." ) } for variant in ["default", "500-rules"] { headless( "config-reload/\(variant)", "instructions +3%; release CPU <= \(variant == "default" ? 2 : 15) ms", "Disk reload and AppliedConfiguration conversion run on ConfigStore's actor; async wall time is diagnostic, not a synchronous instruction gate.", iterations: 1) } headless( "motion-soak/30x10000", "retained bytes after stop within +/- 64 KiB; no idle display source", "Retained malloc-zone bytes are process-wide diagnostics, not total allocations or a leak verdict; motion lifetime fixes pending.", iterations: 1) headless("CoalescerProMotionJitter", "exactly one dispatch per app per tick with +/- 3e-11 s jitter", motion) headless( "AXWriteFastPathCalls", "non-final <= 1 position call; final <= 5 AX calls", "Burst writer not implemented. Real executeFrameWrite is driven by counting attribute access; frame getters count their two attribute reads." ) headless("EnhancedUIToggleCount", "two EnhancedUI sets per app per 24-frame burst", platform) headless( "EchoReadsDuringGlide", "zero frame reads per non-final frame; one per window after final", platform, iterations: 1) headless( "PerWindowRateContinuity", "monotonic; >= 100 fps at 8.4 ms; no app-wide snap below 40 ms per window", motion) headless("NeighbourPhaseDivergence", "edge gap/overlap <= 4 pt; intersection area zero", motion) headless("GhostTransition50", "second transition CA commit < 1 ms; zero new layers", overlay, iterations: 3) headless("AnimationTick200", "release tick p99 < 0.1 ms", motion, iterations: 3) headless("AnimationSchedule200", "release schedule p99 < 0.5 ms", motion, iterations: 3) headless( "FocusFastPath/50", "<= 2 AX calls; zero window-list reads; <= 1 main hop; CPU < 0.2 ms", platform, iterations: 3) headless( "FocusLatencyWithHungApp", "app B focus applied < 2 ms while app A windows blocks 350 ms", platform, iterations: 1) headless( "CreatedToWriteHops", "speculative write before engine delivery; callback frame matches layout", "Published NativeEngineWorld target, real AppThread created-placement seam and executeFrameWrite with counting accessors. Counts synthetic frame attribute operations and fact methods, not native AX IPC or executor hops; live single-move proof remains external.", iterations: 3) headless( "AppWriteBatch/20", "<= 8 AX calls/window; no O(N) lookup; one executor job", "Real executeFrameWrite calls measured for 20 counting windows; production executor job and lookup instrumentation are absent, so no job/lookup count is fabricated." ) headless( "FactsReadPerWindow", "<= 3 batched AX calls per window", "Counts WindowFactsAccess methods, not native IPC. Typed batch decoding has unit coverage; native facts-read latency still needs a trusted fixture." ) for name in ["MoveStormCoalesce", "MoveStormCoalesce/paced"] { headless( name, "500 dirty notifications; latest frame delivered; zero enumerations", "Real NativeEngineWorld and worker mailbox read counting frame accessors at delivery. Burst drains every 25 notifications; paced drains each notification. Synthetic attribute operations are not native AX IPC or live drag latency.", iterations: 1) } headless("SpaceChangeTurn", "one Space read; only changed displays suspended", platform, iterations: 1) headless( "SettleReconcileCost", "5 apps x 6 windows: zero facts reads; <= 1 window-list read", platform, iterations: 1) headless("WindowListDecode/200", "release CPU < 0.3 ms", platform) headless( "WatchdogBeginEnd", "release CPU < 50 ns; zero timer allocations", "Real AXCallWatchdog begin/end with native deadline timer; persistent worker timer optimization pending, timer allocations not inferred.", iterations: 100) for count in [50, 200] { headless("reduce.batch.mixed8.\(count)", "release CPU <= 2 ms at 50; allocation bytes scale linearly", core) headless("layout.edges.columns.\(count)", "release CPU <= 0.5 ms at 200; no crash", core, iterations: 3) headless( "engine.turn.wall.\(count)", "wall p99 <= 2 ms at 50; report only on noisy host", core, iterations: 3) } for layout in [Layout.columns, .rows, .accordion] { headless( "layout.arrange.\(layout.rawValue).200", "release CPU <= 0.5 ms; no recursion crash", core, iterations: 3) } for subscribers in [1, 4] { headless( "engine.snapshot.publish.\(subscribers)subs", "release CPU <= 50 us; includes next-turn copy cost", core ) } headless("Overlay/HighlightUpdate/10-unchanged", "CPU < 50 us; zero new layers", overlay) headless("Overlay/HighlightUpdate/10-moved", "CPU < 300 us", overlay) headless( "Overlay/Consume/50-windows", "main-thread CPU < 0.5 ms; privacy reads <= 2 per glide second", overlay, iterations: 3) headless("Overlay/PrivacyBackdrop/update-8-cutouts", "unchanged < 30 us; changed < 200 us", overlay) headless( "Overlay/ThemeChange/10-windows", "CPU < 1 ms", "Explicit appearance-context restyle measures existing update path; live palette invalidation/cache is pending.", iterations: 3) headless( "MenuBar/IconRender", "image < 0.2 ms; cached repeat < 5 us", "Real image(for:) is lazy; image is drawn into a bitmap so the workload actually rasterizes. Rendered-image caching pending." ) headless("Chips/Update/unchanged", "CPU < 20 us; zero orderFront calls", overlay) headless( "TabView/CanvasAndCardRaster/12", "offscreen canvas construction and 2x card raster CPU diagnostic", "Direct card drawing into a bitmap excludes app layout, panel ordering, compositor presentation and input delivery; it is not open-to-first-frame latency. Runner app icon availability depends on the host.", iterations: 1) deferred( "TabView/OpenToFirstFrame/12", .e2e, "open command to first presented frame < 50 ms wall time", "Requires an open-command timestamp and a presentation-confirmed frame marker in the live app, plus an opt-in FixtureApp scenario; offscreen rasterization does not establish presentation latency." ) deferred( "reduce.layoutCallsPerEvent", .headless, "one traverse/undoable event; zero/focus", "Traversal observers cover warm focus and edit bounds in core behavior tests; a standalone timing workload has not been wired into this catalog." ) deferred( "undo.position.columns.200", .headless, "CPU <= 100 us", "TileTree.undoPosition is fileprivate and cannot be isolated through @testable; needs a narrow internal accessor or traversal counter." ) deferred( "MotionBatchMainActorOverhead", .signpost, "dispatch-to-receipt minus AppThread job < 0.2 ms", "Write receipt does not expose measured AppThread job duration; fake duration subtraction would invent overhead." ) headless("DisplayChangeLatency", "reconfiguration completion to display publish < 60 ms", nil, iterations: 1) headless( "DisplayChangeLatency/screen-only", "screen-only quiet period 200 ms", "Process counters across the native timer wait include unrelated AppKit work; gate scheduling and completion instead.", iterations: 1) headless("DisplayChangeScheduling/screen-only", "latest deadline scheduling cost", nil, iterations: 100) deferred( "window-list-read/live", .e2e, "none; report p50/p99/max", "Live CGWindowList depends on the user's windows and WindowServer load; excluded from permission-free deterministic smoke." ) for (scenario, budget) in [ ("swap-2-windows", "starved <= 1; first move p50 <= 1 frame, p95 <= 2 frames; settle <= 250 ms"), ("layout-change-10", "starved <= 2%; max gap <= 2 refreshes"), ("layout-change-30", "starved <= 5%; initially reporting only"), ("hotkey-focus-move", "first move p50 <= 1 frame + write latency"), ("slow-neighbour", "normal window starved <= 1; first move delta <= 2 ms"), ("new-window-to-tile", "first write p50/p95 <= 8/16 ms; tiled <= 20/40 ms"), ] { deferred( scenario, .e2e, budget, "Requires opt-in FixtureApp frame/vsync recording and Parcel Accessibility grant; never launches live windows in headless smoke." ) } for state in ["settled", "after-space-switch", "after-config-reload"] { deferred( "idle/\(state)", .e2e, "60 s: CPU < 5 ms; instructions < 5M; interrupt/package wakeups <= 2", "Requires a separately launched granted Parcel process and a 60-second quiet window; not headless workload." ) } deferred( "soak/30x2000", .e2e, "footprint < 40 MB; tail slope < 8 KiB/command", "Requires live fixture windows and process footprint samples; PARCEL_E2E=1 and PARCEL_SOAK=1 only.") deferred( "leaks/30-windows", .e2e, "zero leaks", "Requires debug-only task inspection, stack logging and live process memgraph; not headless.") deferred( "Overlay/BorderLag", .signpost, "<= 1 frame of displacement; edge offset p95 <= 2 pt", "Needs engine tick/confirmed AX geometry correlation and opt-in live capture; no window visibility in headless smoke." ) for (name, budget) in [ ("overlay.render", "<= 1 render/display/frame"), ("motion.dispatch", "one dispatch/app/tick"), ("ax.write", "one position call/non-final frame; report calls/per-window ms/final"), ("ax.read.frame", "zero non-final echo reads; one final reconcile/window"), ("ax.enhancedUI.toggle", "two toggles/app/burst"), ("motion.batch", "actor overhead < 0.2 ms"), ("appthread.callback", "AX arrival starts detection interval"), ("world.refresh", "apps progress independently; report AX calls"), ("space.notify", "notification-to-placement interval"), ("space.read", "one read/change"), ("space.retile", "destination placed before arrival"), ("display.change", "publish < 60 ms"), ("appthread.speculativeWrite", "new-window first write < 8 ms p50"), ("menu.render", "closed menu renders <= distinct layout changes"), ] { deferred( name, .signpost, budget, "Requires a live trace sink and native workload; production trace sites/counters are integrated separately." ) } let traceLanes: [(String, [String])] = [ ("pointsOfInterest", ["Command", "Event to settled"]), ("Engine", ["Detect", "Apply", "Layout", "Diff", "Reduce", "Plan", "Publish", "Event to first write"]), ("Input", ["Tap callback", "Hotkey dispatch"]), ("Motion", ["Tick", "Write", "Settle", "Snap"]), ("Overlay", ["Overlay update", "Ghost render"]), ("Platform", ["Window list read", "Space read", "Display reconfigure"]), ("Config", ["Reload"]), ] for (category, intervals) in traceLanes { for interval in intervals { deferred( "trace/\(category)/\(interval)", .signpost, "diagnostic interval; correlate with frame, decision and write budgets", "Requires an attached live signpost recorder; excluded from deterministic headless baseline coverage." ) } } return values }() static var names: Set { Set(entries.filter { $0.kind == .headless && $0.status == .executable }.map(\.name)) } static var definitions: [String: Int] { Dictionary(uniqueKeysWithValues: entries.filter { names.contains($0.name) }.map { ($0.name, $0.iterations) }) } static func definition(named name: String) -> BenchmarkCatalogEntry { guard let entry = entries.first(where: { $0.name == name }) else { preconditionFailure("Uncatalogued benchmark: \(name)") } return entry } }