MTGBench improvement loop

Overview · Experiment index

Iteration 40: Materialize only copy-layer effects for the copy discovery pass

state rejected — failed gate ir4k
switch PHASE_COPY_GATHER_SPECIALIZATION_LEGACY · branch loop/it40 · base 4ec0b9ef1 · candidate 8dddb0fa4 · took 1h 23m

Results

Verdict: TOO SMALL: only 0.09% fewer instructions, under the 0.3% floor. Cycles moved +6.19%, within this machine's noise (±4.5%): 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.09% instructions, same-arm spread 0.032%, equal work: yes, fingerprints match: yes-1% retain-0.3% kill0-0.09%
ArmRun 1 instructionsRun 2ActionsInstr / actioncontract msapply ms
legacy21,542,581,18721,549,403,8924,0005,386,4982,3762,285
optimized21,526,199,32321,527,965,4944,0005,381,7712,4332,376
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+6.19% — cycles-neutral (same-arm spread 4.46%)same within noise
IPC (instructions per cycle, higher is better)0.965 / 1.016worse
backend stall / frontend stall (share of cycles)17.6% / 19.4%  ·  44.5% / 41.3%less waiting
L1D / L2D refills per 1k instructions (cache misses)13.07 / 12.98  ·  11.43 / 11.45same
branch mispredicts per 1k instructions6.012 / 5.953same
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.19% fewer instructions, under the 0.3% floor. Cycles moved +0.67%, within this machine's noise (±8.3%): the time effect is too small to see here; only the PC wall-clock can say. Watch: branch mispredicts +7% per instruction, so part of the saving may be paid back as slower memory or branching. The final word is always the PC wall-clock.
Gate: 4,000 actions (verdict) — -0.19% instructions, same-arm spread 0.001%, 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.19%
ArmRun 1 instructionsRun 2ActionsInstr / actioncontract msapply ms
legacy77,440,018,05877,440,729,63611,4186,782,30619,18212,713
optimized77,289,044,06677,290,069,06411,4186,769,09820,90714,030
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.67% — cycles-neutral (same-arm spread 8.33%)same within noise
IPC (instructions per cycle, higher is better)0.873 / 0.869same
backend stall / frontend stall (share of cycles)22.4% / 20.5%  ·  43.1% / 45.5%more waiting
L1D / L2D refills per 1k instructions (cache misses)17.55 / 17.54  ·  14.16 / 13.96same
branch mispredicts per 1k instructions5.589 / 5.233more
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: 5 minexecutor: 40 minreviewer: 0 minexecutor: 19 minreviewer: 0 mingate fmt: 0 mingate build: 9 mingate ir1k: 1 mingate ir4k: 3 min
planner 5mexecutor 40mreviewer 0mexecutor 19mreviewer 0mgate fmt 0mgate build 9mgate ir1k 1mgate ir4k 3m
executor: 10,617,818 in / 25,461 out tokensplanner: 1,817,729 in / 6,496 out tokensreviewer: 48,810 in / 2,213 out tokens

Mechanism. At layers.rs:6283, gather_active_effects_for_layer collects every active continuous effect and then discards effects outside the requested layer. Its production caller is the copy fixed-point pass. Add a copy-specific collection mode that skips ordinary non-copy modifications before cloning their payloads. Keep expanding grant forms on the existing expansion path and filter their emitted effects afterward.

Evidence. docs/stage0-decision-memo.md:L4904, xn5.67, measures evaluate_layers at 11.6% inclusive CPU and attributes allocator traffic to that family. Current source performs the all-layer collection for copy discovery and subsequently gathers effects again after layer 1. The profile bounds the containing family, but does not isolate the removable materialization cost; this is a ceiling, not a measured saving. Later loop optimizations make the profile historical.

Counter and kill threshold. Existing xn5.67 evaluate_layers inclusive profile row: 11.6%; allocator-owner report also attributes 1.1% CPU one level above allocations to evaluate_layers. These overlap and must not be added. Expected instruction reduction: 0.6–1.4% per action at 4,000 actions, an unmeasured hypothesis; allocation savings may be understated by instructions.

Invariant. The specialized collector must return exactly the legacy collector's Layer::Copy subsequence, preserving emission order, definition/modification indices, provenance, conditions and payloads. It must gather from the current board on every fixed-point generation. Expansion forms cannot be screened solely by their outer modification's layer.

Agent steps

RoleHarness / modelTimeExitTokens in / outNote
plannercodex / gpt-6.1-sol5m 34s01,817,729 / 6,496
executorcodex / gpt-6-luna40m 48s07,657,635 / 18,427
reviewercodex / gpt-6.1-sol0m 55s025,501 / 1,308
executorcodex / gpt-6-luna19m 58s02,960,183 / 7,034
reviewercodex / gpt-6.1-sol0m 42s023,309 / 905

Gates

GateResultExitDetail
fmtpass0cargo fmt --all -- --check
buildpass0pwsh -NoProfile -File scripts/bench_phase.ps1 -Mode build -CargoProfile bench-fast-inc -Label it40-build
ir1kpass0Ir -0.09% within +/-1%, same-arm spread 0.0317% | optimized 21,525,711,710 vs legacy 21,545,637,706 instructions; fingerprints match: True
ir4kFAIL0Ir -0.19% within +/-1%, same-arm spread 0.0169% | optimized 77,286,895,370 vs legacy 77,436,123,519 instructions; fingerprints match: True

Write-up: 2026-10-03 - Loop iteration 40: Materialize only copy-layer effects for the copy discovery pass (rejected)

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

Automated loop result on homelab (aarch64). Switch PHASE_COPY_GATHER_SPECIALIZATION_LEGACY, mechanism class allocation. Mechanism: At layers.rs:6283, gather_active_effects_for_layer collects every active continuous effect and then discards effects outside the requested layer. Its production caller is the copy fixed-point pass. Add a copy-specific collection mode that skips ordinary non-copy modifications before cloning their payloads. Keep expanding grant forms on the existing expansion path and filter their emitted effects afterward. Invariant: The specialized collector must return exactly the legacy collector's Layer::Copy subsequence, preserving emission order, definition/modification indices, provenance, conditions and payloads. It must gather from the current board on every fixed-point generation. Expansion forms cannot be screened solely by their outer modification's layer.

gatepasseddetail
fmtyescargo fmt --all -- --check
buildyespwsh -NoProfile -File scripts/bench_phase.ps1 -Mode build -CargoProfile bench-fa
ir1kyesIr -0.09% within +/-1%, same-arm spread 0.0317%
ir4kNOIr -0.19% within +/-1%, same-arm spread 0.0169%

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:10 · read-only · refreshes every 30 s