MTGBench improvement loop

Overview · Experiment index

Iteration 48: Fuse departure and destination zone-dependency scans

state rejected — failed gate ir4k
switch PHASE_ZONE_DEPENDENCY_FUSED_SCAN_LEGACY · branch loop/it48 · base 4ec0b9ef1 · candidate d807739e9 · took 1h 42m

Results

Verdict: MARGINAL: 0.33% fewer instructions, between 0.3% and 1%. It is sent to the PC wall-clock check instead of being kept outright. Cycles moved -0.26%, within this machine's noise (±2.4%): the time effect is too small to see here; only the PC wall-clock can say. Cache misses and branch mispredicts per instruction are about unchanged, so no hidden cost shows up. The final word is always the PC wall-clock.
Gate: 1,000 actions (screen) — -0.33% instructions, same-arm spread 0.010%, equal work: yes, fingerprints match: yes-1% retain-0.3% kill0-0.33%
ArmRun 1 instructionsRun 2ActionsInstr / actioncontract msapply ms
legacy21,540,436,03221,541,396,9804,0005,385,2292,6952,864
optimized21,468,561,89121,470,650,1264,0005,367,4023,2663,185
Instruction counts are deterministic and machine-specific (aarch64 homelab). contract and apply ms are wall time under perf: indicative only, not a clean timing.
Hardware counters (optimized / legacy)ValueReading
cycles, minimum of the repeats-0.26% — cycles-neutral (same-arm spread 2.38%)same within noise
IPC (instructions per cycle, higher is better)1.015 / 1.026same
backend stall / frontend stall (share of cycles)17.1% / 18.7%  ·  44.3% / 42.1%less waiting
L1D / L2D refills per 1k instructions (cache misses)12.97 / 13.10  ·  11.29 / 11.09same
branch mispredicts per 1k instructions5.777 / 5.728same
Green = better, red = worse, grey = about the same (5% band). Cycles are the closest thing to time that the shared VM does not distort. Fewer instructions with more cycles means the saving does not show up as time; such a candidate goes to the workstation wall-clock instead of being retained.
Verdict: TOO SMALL: only 0.29% fewer instructions, under the 0.3% floor. Cycles moved +2.52%, within this machine's noise (±5.9%): the time effect is too small to see here; only the PC wall-clock can say. Cache misses and branch mispredicts per instruction are about unchanged, so no hidden cost shows up. The final word is always the PC wall-clock.
Gate: 4,000 actions (verdict) — -0.29% instructions, same-arm spread 0.020%, equal work: yes, fingerprints match: yes
Gate FAILED: the harness refused this A/B (exit 0); see the write-up below. These counts are not a valid measurement.
-1% retain-0.3% kill0-0.29%
ArmRun 1 instructionsRun 2ActionsInstr / actioncontract msapply ms
legacy77,423,777,72977,439,617,15711,4186,781,54620,03412,437
optimized77,208,262,07777,205,827,75611,4186,761,87120,46413,753
Instruction counts are deterministic and machine-specific (aarch64 homelab). contract and apply ms are wall time under perf: indicative only, not a clean timing.
Hardware counters (optimized / legacy)ValueReading
cycles, minimum of the repeats+2.52% — cycles-neutral (same-arm spread 5.85%)same within noise
IPC (instructions per cycle, higher is better)0.875 / 0.878same
backend stall / frontend stall (share of cycles)19.4% / 20.1%  ·  46.5% / 45.6%same
L1D / L2D refills per 1k instructions (cache misses)17.51 / 17.52  ·  14.05 / 14.09same
branch mispredicts per 1k instructions5.382 / 5.528same
Green = better, red = worse, grey = about the same (5% band). Cycles are the closest thing to time that the shared VM does not distort. Fewer instructions with more cycles means the saving does not show up as time; such a candidate goes to the workstation wall-clock instead of being retained.

Where the time went

planner: 9 minexecutor: 58 minreviewer: 0 mingate fmt: 0 mingate build: 27 mingate ir1k: 1 mingate ir4k: 3 min
planner 9mexecutor 58mreviewer 0mgate fmt 0mgate build 27mgate ir1k 1mgate ir4k 3m
executor: 10,868,470 in / 18,976 out tokensplanner: 4,319,585 in / 11,353 out tokensreviewer: 23,231 in / 641 out tokens

Mechanism. At layers.rs:4538, static_layer_dependency_for_zone_transition traverses static sources separately for the departure and destination zones. Traverse once and test static_definition_reads_zone_membership(def, from) || static_definition_reads_zone_membership(def, to) for each definition.

Evidence. xn5.67, docs/stage0-decision-memo.md:L4904, and bench/reports/uprof-xn565-20260923-owners-all.txt attribute 0.7% of process CPU to any_active_static_reads_zone_membership. zones.rs calls the paired query before and after each move. This historical function-level bound includes other callers; the removable second traversal is not separately measured. Preserve both pre-move and post-move queries.

Counter and kill threshold. Existing any_active_static_reads_zone_membership profile row: 0.7% CPU. Expected instruction reduction: 0.3–0.5% per action at 4,000 actions, with low confidence because paired-call coverage is unmeasured. Apply the loop's unchanged retention, marginal and drop tiers.

Invariant. Existential disjunction distributes over the identical immutable source and definition population. Preserve source admission, currently-false condition readers, index fallback and every invalidation checkpoint. Permanently compare the fused result with the original two queries across zone pairs and compare resulting transition states.

Agent steps

RoleHarness / modelTimeExitTokens in / outNote
plannercodex / gpt-6.1-sol9m 30s04,319,585 / 11,353
executorcodex / gpt-6-luna58m 49s010,868,470 / 18,976
reviewercodex / gpt-6.1-sol0m 33s023,231 / 641

Gates

GateResultExitDetail
fmtpass0cargo fmt --all -- --check
buildpass0pwsh -NoProfile -File scripts/bench_phase.ps1 -Mode build -CargoProfile bench-fast-inc -Label it48-build
ir1kpass0Ir -0.33% within +/-1%, same-arm spread 0.0163% | optimized 21,468,790,594 vs legacy 21,539,998,562 instructions; fingerprints match: True
ir4kFAIL0Ir -0.29% within +/-1%, same-arm spread 0.0205% | optimized 77,207,805,125 vs legacy 77,433,235,099 instructions; fingerprints match: True

Write-up: 2026-10-04 - Loop iteration 48: Fuse departure and destination zone-dependency scans (rejected)

Status: rejected (loop, instruction-count gate; wall-clock not yet confirmed)

Automated loop result on homelab (aarch64). Switch PHASE_ZONE_DEPENDENCY_FUSED_SCAN_LEGACY, mechanism class compute. Mechanism: At layers.rs:4538, static_layer_dependency_for_zone_transition traverses static sources separately for the departure and destination zones. Traverse once and test static_definition_reads_zone_membership(def, from) || static_definition_reads_zone_membership(def, to) for each definition. Invariant: Existential disjunction distributes over the identical immutable source and definition population. Preserve source admission, currently-false condition readers, index fallback and every invalidation checkpoint. Permanently compare the fused result with the original two queries across zone pairs and compare resulting transition states.

gatepasseddetail
fmtyescargo fmt --all -- --check
buildyespwsh -NoProfile -File scripts/bench_phase.ps1 -Mode build -CargoProfile bench-fa
ir1kyesIr -0.33% within +/-1%, same-arm spread 0.0163%
ir4kNOIr -0.29% within +/-1%, same-arm spread 0.0205%

Wall-clock confirmation on the workstation is required before this counts as a speedup; instruction count is a screen, not a time prediction.

generated 2026-11-28 18:17:12 · read-only · refreshes every 30 s