MTGBench improvement loop

Overview · Experiment index

Iteration 22: Borrow pending mana activations during synchronous cost payment

state rejected — failed gate ir4k
switch PHASE_MANA_COST_PENDING_BORROW_LEGACY · branch loop/it22 · base 4ec0b9ef1 · candidate 2e852440c · took 1h 38m

Results

Verdict: TOO SMALL: only 0.08% fewer instructions, under the 0.3% floor. Cycles agree (-3.12%): it should be faster in real time too. 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.08% instructions, same-arm spread 0.010%, equal work: yes, fingerprints match: yes-1% retain-0.3% kill0-0.08%
ArmRun 1 instructionsRun 2ActionsInstr / actioncontract msapply ms
legacy21,547,784,06421,545,538,0014,0005,386,6652,8962,833
optimized21,529,517,30121,528,877,5004,0005,382,2992,2942,261
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-3.12% — cycles-faster (same-arm spread 1.54%)faster
IPC (instructions per cycle, higher is better)1.038 / 1.002same
backend stall / frontend stall (share of cycles)18.0% / 16.5%  ·  42.0% / 45.2%more waiting
L1D / L2D refills per 1k instructions (cache misses)13.00 / 13.00  ·  10.92 / 11.39same
branch mispredicts per 1k instructions5.596 / 6.036fewer
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.10% fewer instructions, under the 0.3% floor. Cycles moved +0.35%, within this machine's noise (±1.7%): 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.10% instructions, same-arm spread 0.033%, 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.10%
ArmRun 1 instructionsRun 2ActionsInstr / actioncontract msapply ms
legacy77,464,272,79777,448,457,04811,4186,783,70719,11112,618
optimized77,365,570,08277,391,055,68711,4186,776,87119,27412,150
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.35% — cycles-neutral (same-arm spread 1.70%)same within noise
IPC (instructions per cycle, higher is better)0.903 / 0.910same
backend stall / frontend stall (share of cycles)19.9% / 21.6%  ·  44.8% / 42.8%less waiting
L1D / L2D refills per 1k instructions (cache misses)17.47 / 17.52  ·  13.78 / 13.70same
branch mispredicts per 1k instructions5.116 / 5.006same
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: 39 minreviewer: 0 minexecutor: 25 minreviewer: 0 mingate fmt: 0 mingate build: 17 mingate ir1k: 1 mingate ir4k: 3 min
planner 9mexecutor 39mreviewer 0mexecutor 25mreviewer 0mgate fmt 0mgate build 17mgate ir1k 1mgate ir4k 3m
executor: 11,058,111 in / 30,506 out tokensplanner: 3,687,562 in / 10,976 out tokensreviewer: 42,785 in / 1,190 out tokens

Mechanism. mana_abilities.rs:3623 deep-clones PendingManaAbility for every cost component before pay_mana_ability_cost_component knows whether payment will suspend. Pass a borrowed-or-owned pending value: borrow during optimized synchronous payment and materialize ownership only when storing a continuation. Keep existing parent snapshots unchanged.

Evidence. xn5.67, docs/stage0-decision-memo.md:4904, measures continue_mana_ability_cost_payment_in_node at 16.7% inclusive CPU. Its referenced owners-all.txt attributes 3.6% CPU to an ability-tree clone owner, with 1.3% allocator ownership in owners-alloc.txt. PendingManaAbility contains an owned ability snapshot and continuation payloads. These overlapping profile rows bound relevant families; this particular clone has no isolated timer. This targets component-entry cloning, distinct from the rejected tap-parent construction experiment.

Counter and kill threshold. Existing xn5.67 mana-payment and ability-clone profile rows. Expected instruction reduction: 0.5–1.1% per action at 4,000 actions, an unmeasured planning estimate. Copy and allocation savings may register only in the marginal band; the exact removable share remains unknown.

Invariant. Synchronous component payment reads the pending activation without modifying it. A suspension must own exactly the same pending payload as today. Preserve selected-object cursors, deferred events, parent snapshots, source-loss fallback, journal nodes, errors and continuation ordering. Add permanent arm-to-arm regressions for synchronous composite payment and replacement suspension at different components, followed by identical resumption.

Agent steps

RoleHarness / modelTimeExitTokens in / outNote
plannercodex / gpt-6.1-sol9m 59s03,687,562 / 10,976
executorcodex / gpt-6-luna39m 34s04,702,928 / 11,605
reviewercodex / gpt-6.1-sol0m 24s020,458 / 526
executorcodex / gpt-6-luna25m 19s06,355,183 / 18,901
reviewercodex / gpt-6.1-sol0m 32s022,327 / 664

Gates

GateResultExitDetail
fmtpass0cargo fmt --all -- --check
buildpass0pwsh -NoProfile -File scripts/bench_phase.ps1 -Mode build -CargoProfile bench-fast-inc -Label it22-build
ir1kpass0Ir -0.09% within +/-1%, same-arm spread 0.0366% | optimized 21,529,638,277 vs legacy 21,548,915,060 instructions; fingerprints match: True
ir4kFAIL0Ir -0.11% within +/-1%, same-arm spread 0.0347% | optimized 77,373,617,461 vs legacy 77,456,543,256 instructions; fingerprints match: True

Write-up: 2026-10-02 - Loop iteration 22: Borrow pending mana activations during synchronous cost payment (rejected)

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

Automated loop result on homelab (aarch64). Switch PHASE_MANA_COST_PENDING_BORROW_LEGACY, mechanism class copy. Mechanism: mana_abilities.rs:3623 deep-clones PendingManaAbility for every cost component before pay_mana_ability_cost_component knows whether payment will suspend. Pass a borrowed-or-owned pending value: borrow during optimized synchronous payment and materialize ownership only when storing a continuation. Keep existing parent snapshots unchanged. Invariant: Synchronous component payment reads the pending activation without modifying it. A suspension must own exactly the same pending payload as today. Preserve selected-object cursors, deferred events, parent snapshots, source-loss fallback, journal nodes, errors and continuation ordering. Add permanent arm-to-arm regressions for synchronous composite payment and replacement suspension at different components, followed by identical resumption.

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.0366%
ir4kNOIr -0.11% within +/-1%, same-arm spread 0.0347%

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