# Engine core measurements Measured 2026-10-31 against production revision `1cf7890`, before engine changes. Host: `Mac15,10;cores=14`, macOS 15.7.7 (`24G720`), Apple Swift 6.2.4. All 32 release cases completed in separate processes. The previously observed large-tree debug crash did **not** reproduce here; this is not evidence of a fix. ## Measurement - Seven samples of 32 operations, after an unmeasured warm-up. Columns below are independent minima; every raw sample and checksum is retained in JSON. - Instructions are real process-wide `proc_pid_rusage` / `RUSAGE_INFO_V4` `ri_instructions` deltas. Zero, failed reads, and non-advancing counters fail. Batched work and counter-read overhead is included, amortized over each batch. - CPU uses the thread CPU clock. Allocation logging is disabled for this pass. - A separate replay counts successful malloc/calloc/realloc requests on the measuring thread through the exported `malloc_logger`. Bytes are **requested allocation traffic**, including the full requested size of realloc, not live heap growth, physical footprint, or retained bytes. Freed allocations still count. A known malloc/realloc probe must return two allocations and 357 bytes; missing or occupied hooks fail rather than supplying a substitute metric. - Normal tests use five 10-window cases and short instrumentation checks, with no timing thresholds. The instruction budget helper's strict +3% boundary, real counter availability, allocation ABI, and hook cleanup are tested. The two-display fixtures have either one window-bearing workspace on the first active display or eight workspaces split evenly across the displays, with one active Space per display. Counts are total windows, not windows per workspace. The tile cap is explicitly unlimited. Cold frames are offset by one point; steady cases use reducer-produced geometry. Inactive frames remain untouched. Floating and edge ticks start from a gesture containing one prior tick and validate undo coalescing. Tiled frame edits exercise observed-frame feedback; they do not imply that a tiled frame observation changes its placement. `mixed8` includes focus observations, floating move/edit, tiled resize feedback, and directional focus. `undo.position` is a **public edge-resize plus undo roundtrip**, including snapshot and layout work, not the private position helper in isolation. It verifies restoration before sampling. Task-local test observers count arrangements and traversals directly; reducer stage tracing alone cannot count internal layout calls. They are unset during normal operation. ## Reproduce Build the smoke tests with `swift test -c release --filter EngineCorePerformanceTests`. For one full case in the current build: ```sh PARCEL_ENGINE_BENCH=1 \ PARCEL_ENGINE_BENCH_CASE=reduce.tileEdgeResized.tick.200 \ PARCEL_ENGINE_BENCH_OUTPUT=/tmp/parcel-engine-edge200.json \ swift test -c release --skip-build --filter EngineCorePerformanceTests ``` The immutable before bundle, copied frameworks/resources, source archive, benchmark sources, loader script, and raw measurements are in the local ignored artifact directory `.build/engine-core-before-1cf7890-20261031T180900Z`. The test binary SHA-256 is `c889cefbacb76a3e6cd742092da7ca8c622285f13db4902051ad3f7302228e84`. On macOS this is a Mach-O bundle, not an executable. The saved bundle was successfully loaded using the toolchain's `usr/libexec/swift/pm/swiftpm-testing-helper --test-bundle-path ` with `--testing-library swift-testing --filter EngineCorePerformanceTests` and `DYLD_FRAMEWORK_PATH` pointing to the platform's developer test frameworks. The artifact's saved runner records every terminal status and continues through failures; it exits unsuccessfully if any case fails. Source edits and subsequent builds cannot replace the saved binary. CMO comparisons are recorded below. ## Before results | Case | Instructions | CPU µs | Allocations | Requested bytes | |---|---:|---:|---:|---:| | reduce.focusObservation.10x1ws | 164,789 | 9.10 | 70 | 11,420 | | reduce.focusObservation.cold.10x1ws | 177,015 | 9.55 | 78 | 13,140 | | reduce.focusObservation.10x8ws | 277,111 | 28.23 | 53 | 14,576 | | reduce.focusObservation.cold.10x8ws | 262,100 | 14.82 | 59 | 15,272 | | reduce.windowFrameEdited.tick.floating.10 | 184,720 | 10.30 | 69 | 11,524 | | reduce.windowFrameEdited.tick.tiled.10 | 158,708 | 9.25 | 55 | 9,752 | | reduce.tileEdgeResized.tick.10 | 1,226,271 | 75.32 | 703 | 74,478 | | reduce.focus.directional.10 | 247,859 | 13.60 | 100 | 18,104 | | reduce.focusObservation.50x1ws | 546,776 | 29.68 | 199 | 48,116 | | reduce.focusObservation.cold.50x1ws | 565,680 | 31.35 | 209 | 54,140 | | reduce.focusObservation.50x8ws | 815,337 | 96.24 | 116 | 34,624 | | reduce.focusObservation.cold.50x8ws | 796,689 | 61.89 | 124 | 36,344 | | reduce.windowFrameEdited.tick.floating.50 | 497,792 | 27.05 | 118 | 49,220 | | reduce.windowFrameEdited.tick.tiled.50 | 465,594 | 31.86 | 104 | 47,448 | | reduce.tileEdgeResized.tick.50 | 10,568,734 | 806.59 | 5,543 | 636,550 | | reduce.focus.directional.50 | 791,480 | 47.20 | 240 | 82,624 | | reduce.focusObservation.200x1ws | 2,022,630 | 115.41 | 661 | 185,548 | | reduce.focusObservation.cold.200x1ws | 2,059,456 | 125.01 | 673 | 209,876 | | reduce.focusObservation.200x8ws | 2,433,978 | 137.98 | 316 | 107,992 | | reduce.focusObservation.cold.200x8ws | 2,545,081 | 140.83 | 326 | 114,016 | | reduce.windowFrameEdited.tick.floating.200 | 1,692,074 | 96.77 | 280 | 189,124 | | reduce.windowFrameEdited.tick.tiled.200 | 1,692,356 | 96.11 | 266 | 187,352 | | reduce.tileEdgeResized.tick.200 | 116,915,007 | 9,109.12 | 53,549 | 6,330,102 | | reduce.focus.directional.200 | 2,852,041 | 174.10 | 716 | 325,016 | | reduce.batch.mixed8.50 | 1,366,320 | 77.84 | 612 | 134,532 | | layout.edges.columns.50 | 784,083 | 47.81 | 346 | 64,990 | | reduce.batch.mixed8.200 | 4,539,435 | 280.01 | 1,982 | 477,444 | | layout.edges.columns.200 | 7,496,636 | 519.47 | 1,756 | 494,846 | | layout.arrange.columns.200 | 360,961 | 23.41 | 10 | 74,508 | | layout.arrange.rows.200 | 420,045 | 25.18 | 10 | 74,508 | | layout.arrange.accordion.200 | 423,570 | 28.25 | 17 | 76,752 | | undo.position.columns.200 | 132,241,853 | 11,102.94 | 55,141 | 8,549,294 | The largest measured costs are edge ticks and the public resize/undo roundtrip, not pure arrangement. At 200 windows they request approximately 6.3 MB and 8.5 MB respectively per operation. Timing came from a loaded host; keep raw instruction counts, CPU time, and allocation traffic separate when comparing. ## Finding outcomes | Finding | Outcome | |---|---| | EC1 | Derived window-to-workspace and ordered-key caches replace repeated sorting and scans. Public model mutations and decoding invalidate them. Inactive frames are visited by workspace membership. | | EC2 | Warm undoable edits reuse the post-edit layout; ordinary focus observations arrange nothing. Edge gestures retain one undo step across batches. Cold edits prepare canonical undo geometry once, then arrange the edit once. First edge captures also require a validation traversal. | | EC3 | Geometry/layout events trigger adaptation; unchanged geometry, capability, variant, defaults, and caps exit early. Focus reconciliation first compares order arrays without constructing sets. | | EC4 | Retile attribution uses indexed ownership. Collectors reserve storage, primary selection uses the first stack directly, and edge membership is prepared once. | | EC5 | Explicit stacks and preorder summaries preserve topology, divider paths, rounding, and order. Gap-specific minimum replay reuses captured leaves without changing the recurrence. The 512-KiB worker probe changes from SIGBUS to success at 200 and 1,000 tiles. | | EC6 | Warm observations retain narrow focus membership, not a full previous state. Undo capture is scoped. Undoable/rollback events still retain previous dictionaries; the one-State-sized-copy-per-batch target is not established. | | EC7 | Directional neighbors reuse warm geometry and select the minimum in one pass, preserving window-ID tie breaks. | | EC8 | CMO was measured before considering annotations. No compiler flag or public ABI annotation was enabled; the instruction results below do not justify it. | | EC9 | No hot-path Codable/string issue was found; no change. | No new public API or dependency was added. Cache helpers and test observers are internal. ## Final named comparisons After the shared harness merged, production `4d3ae23` and `b2143fe` were built with identical package/benchmark overlays and deterministic hashing. This avoids charging intervening model changes to the engine optimization. All 32 named process-counter cases pass the +3% instruction gate. These are seven-sample minima, with allocator traffic replayed separately, not the v5 thread medians. Raw pairs are in `.build/engine-core-final-b2143fe/{before-main,after}`; the validated comparison is `.build/perf-engine-gates/measured-isolated-comparison.json`. | Case | Before instructions | After instructions | Requested bytes before → after | |---|---:|---:|---:| | focusObservation.10x8ws | 296,469 | 36,349 | 14,616 → 4,968 | | focusObservation.50x8ws | 802,674 | 42,733 | 34,664 → 5,032 | | focusObservation.200x8ws | 2,734,106 | 62,046 | 108,032 → 5,032 | | windowFrameEdited.tick.floating.200 | 1,716,620 | 352,253 | 189,164 → 66,476 | | windowFrameEdited.tick.tiled.200 | 1,699,221 | 309,435 | 187,392 → 25,996 | | tileEdgeResized.tick.50 | 10,312,763 | 2,879,192 | 636,590 → 174,784 | | tileEdgeResized.tick.200 | 116,808,116 | 10,690,662 | 6,330,142 → 719,200 | | focus.directional.200 | 2,894,791 | 198,928 | 325,056 → 2,448 | | batch.mixed8.50 | 1,387,375 | 349,628 | 134,628 → 42,064 | | batch.mixed8.200 | 4,609,446 | 733,353 | 477,540 → 144,568 | | edges.columns.200 | 7,474,264 | 1,322,503 | 494,846 → 204,477 | | arrange.columns.200 | 383,158 | 353,356 | 74,508 → 73,336 | | arrange.rows.200 | 442,384 | 415,978 | 74,508 → 73,336 | | arrange.accordion.200 | 445,464 | 359,246 | 76,752 → 73,384 | | undo.position.columns.200 | 130,489,892 | 9,400,259 | 8,549,342 → 766,560 | Mixed-eight allocations fall from 613 to 71 at 50 windows and 1,983 to 71 at 200. Requested bytes scale with window count; this does not prove one retained State-sized copy per batch. Steady 200-window/eight-workspace focus has ten allocations and 5,032 requested bytes, versus 317 and 108,032 before. The added `reduce.nudgeRatio.cold.200` case measures **106,097,549 → 7,321,223 instructions**, and **6,426.25 → 463.65 µs** minimum CPU. Behavior tests verify two arrangements for a cold edit (canonical before plus post-edit), one for a warm edit, and restoration to canonical geometry. Raw cold-ratio reports are `.build/perf-engine-gates/measured-cold-{main-before,after}.json`. The rejected direct-descent experiment and generic minimum replay showed why CPU alone is insufficient: ordinary arrangement and snapshot instructions grew, while compressed-gap instructions more than doubled. Preorder summaries replay the same minimum recurrence from cached leaves; direct visibility projection avoids extra collectors. Focused checksums and the uncached geometry oracle agree. ## Shared v5 gate Five interleaved A/B rounds passed **128 cases**, with **72 synchronous cases gated** and no instruction or bootstrap-CPU regressions. Both builds use the same v5 overlay, host, macOS build, Swift toolchain, sampling rules, and `selfcounts` thread counters. The largest gated instruction ratio is **+2.29%**, below the +3% boundary. No reporting-only workload was promoted outside core. These values are medians of the five reports' instruction measurements: | Case | Before instructions/op | After instructions/op | |---|---:|---:| | reduce.focusObservation.200x8ws | 1,715,408 | 491,643 | | reduce.windowFrameEdited.tick.200 | 1,298,998 | 200,769 | | reduce.tileEdgeResized.tick.200 | 9,471,853 | 4,306,887 | | reduce.batch.mixed8.200 | 2,373,070 | 1,229,360 | | layout.edges.columns.200 | 107,574 | 67,173 | | layout.arrange.columns.200 | 221,322 | 190,832 | | layout.arrange.rows.200 | 221,825 | 191,435 | | layout.arrange.accordion.200 | 226,093 | 193,656 | | compressed-gap/columns/200 | 6,666,869 | 2,293,942 | | snapshot-menu/200 | 234,065 | 239,501 | The shared fixtures retain the configured tile cap and start without a reducer layout cache; the isolated fixtures are explicitly uncapped and distinguish warm/cold paths. Their similarly named measurements are not interchangeable. The shared cold 200-window/eight-workspace focus minimum is 28.95 µs; its 20-µs absolute quiet-host target is not certified. Steady isolated focus stays below that target without arranging frames. Async engine cases report wall time, not thread instruction counts. After-run wall-p99 medians are **67.88 µs** for a 50-window turn, **219.63 µs** at 200, and **70.88/66.88 µs** for one/four-subscriber publication including the next turn. These are headless reporting-only observations, not quiet live budgets. The authoritative summary is `build/bench-ab/measured-summary.json`; all ten raw reports are in `build/bench-ab/run.PWsFgK/{base,head}/measured-round-*.json`. ## Validation Plain debug and release builds passed without warnings. Both full unit modes passed **3,121 tests in 298 suites**. `make lint`, strict recursive Swift format, the naming guard, and all **28 shell suites** passed. Live e2e skipped with the normal opt-in message and no app launch. One integration repair replaces a real ten-second wait in the existing floating rule cancellation test with its already-available manually completed fake-command gate. Actor contention could finish the old wait before cancellation. No engine rule behavior or test-support API changed. ## CMO decision Both default and `-cross-module-optimization` release binaries at `e0ec425` ran all 32 isolated cases and the then-current common benchmark suite. Five further interleaved rounds of four representative cases used the median of each round's minimum instruction count: | Case | Default instructions | CMO instructions | Change | |---|---:|---:|---:| | focusObservation.200x8ws | 34,299 | 35,382 | +3.16% | | tileEdgeResized.tick.200 | 10,517,666 | 10,620,344 | +0.98% | | batch.mixed8.200 | 662,367 | 670,639 | +1.25% | | arrange.columns.200 | 376,333 | 380,340 | +1.06% | The geometric mean is +1.61% instructions; focus exceeds the +3% boundary. Separate CPU minima appeared better with CMO, but host conditions changed and calibration differed substantially. They are not evidence that CMO helped. Raw paired trials are in `.build/cmo-interleaved-e0ec425/summary.json`. ## Remaining proof limits The isolated frame-edit cases translate frames; the shared v5 workloads also exercise actual size changes. The shared harness includes full engine turns and one/four-subscriber publication. Those async cases do not claim thread instruction counts. Quiet live timing, actual AX writes, and a retained-snapshot copy budget remain unverified. The isolated undo workload measures the public roundtrip, not the private position helper. No quiet baseline, Screen Recording grant, or SIP-dependent operation was needed or fabricated. Input follow-up: some headless factories still construct events with nil/shared sources (`HotKeyPoster.events`, the input benchmark, and two inspection tests). Use private event sources when that package next changes. This review did not prove construction contaminated HID state, post cleanup events, or alter input code; the live-test engineer owns that investigation.