MTGBench improvement loop

Overview · Experiment index

Iteration 21: Skip unused parent-continuation allocation for tap mana costs

state rejected — failed gate ir4k
switch PHASE_MANA_TAP_PARENT_LEGACY · branch loop/it21 · base 4ec0b9ef1 · candidate a0816492a · took 58m 41s

Results

Verdict: TOO SMALL: only 0.11% fewer instructions, under the 0.3% floor. Cycles moved -0.10%, within this machine's noise (±5.8%): 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.11% instructions, same-arm spread 0.011%, equal work: yes, fingerprints match: yes-1% retain-0.3% kill0-0.11%
ArmRun 1 instructionsRun 2ActionsInstr / actioncontract msapply ms
legacy21,781,942,00921,780,843,9764,0005,445,3482,3722,257
optimized21,757,956,98921,755,603,9914,0005,439,1952,5592,481
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.10% — cycles-neutral (same-arm spread 5.76%)same within noise
IPC (instructions per cycle, higher is better)1.004 / 1.025same
backend stall / frontend stall (share of cycles)19.0% / 20.0%  ·  41.8% / 40.1%same
L1D / L2D refills per 1k instructions (cache misses)12.85 / 12.88  ·  11.13 / 10.98same
branch mispredicts per 1k instructions5.596 / 5.402same
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.16% fewer instructions, under the 0.3% floor. Cycles moved +1.39%, within this machine's noise (±8.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.16% instructions, same-arm spread 0.026%, 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.16%
ArmRun 1 instructionsRun 2ActionsInstr / actioncontract msapply ms
legacy78,427,673,74078,444,630,38111,4186,869,51819,86213,015
optimized78,301,395,66678,321,805,70911,4186,858,60917,23511,254
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+1.39% — cycles-neutral (same-arm spread 8.66%)same within noise
IPC (instructions per cycle, higher is better)0.924 / 0.913same
backend stall / frontend stall (share of cycles)26.8% / 25.2%  ·  36.8% / 38.8%more waiting
L1D / L2D refills per 1k instructions (cache misses)17.30 / 17.34  ·  13.70 / 13.62same
branch mispredicts per 1k instructions5.293 / 5.179same
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: 8 minexecutor: 35 minreviewer: 0 mingate fmt: 0 mingate build: 8 mingate ir1k: 1 mingate ir4k: 3 min
planner 8mexecutor 35mreviewer 0mgate fmt 0mgate build 8mgate ir1k 1mgate ir4k 3m
executor: 6,367,348 in / 16,707 out tokensplanner: 2,192,035 in / 10,049 out tokensreviewer: 23,222 in / 650 out tokens

Mechanism. In mana_abilities.rs::pay_mana_ability_cost_component, the fallback branch clones the cursor and pending ability and allocates two boxes to construct ManaAbilityCostParent. For an AbilityCost::Tap leaf, pay_mana_ability_cost_with_choices only calls tap_source and never reads that parent. Omit parent construction for precisely this leaf and pass None; preserve construction for every other cost.

Evidence. docs/stage0-decision-memo.md:L4904, xn5.67, measures continue_mana_ability_cost_payment_in_node at 16.7% inclusive CPU. Its recorded owners-all artifact attributes 3.6% CPU to ability::impl$1662::clone, and owners-alloc attributes 1.3% to allocation under that clone owner. These are overlapping family ceilings, not a measured removable slice. Source inspection identifies unconditional continuation construction on the tap path. This differs from xn5.36's deferred outer auto-tap setup cut.

Counter and kill threshold. Existing xn5.67 mana-payment inclusive row and clone allocation-owner rows bound the family; this construction has no isolated timer. Expected instruction reduction: 0.5–1.2% per action at 4,000 actions, an unmeasured estimate. Allocation savings may register only in the marginal band.

Invariant. The Tap arm does not consume the parent argument. Removing its unused snapshot must preserve cost payment, errors, event order, replacement pauses, unpaid suffixes, journal records and all three fingerprints. Every non-Tap cost retains its existing parent ownership.

Agent steps

RoleHarness / modelTimeExitTokens in / outNote
plannercodex / gpt-6.1-sol8m 52s02,192,035 / 10,049
executorcodex / gpt-6-luna35m 49s06,367,348 / 16,707
reviewercodex / gpt-6.1-sol0m 30s023,222 / 650

Gates

GateResultExitDetail
fmtpass0cargo fmt --all -- --check
buildpass0pwsh -NoProfile -File scripts/bench_phase.ps1 -Mode build -CargoProfile bench-fast-inc -Label it21-build
ir1kpass0Ir -0.12% within +/-1%, same-arm spread 0.0252% | optimized 21,756,131,454 vs legacy 21,783,039,645 instructions; fingerprints match: True
ir4kFAIL0Ir -0.16% within +/-1%, same-arm spread 0.0265% | optimized 78,308,083,887 vs legacy 78,432,149,678 instructions; fingerprints match: True

Write-up: 2026-10-02 - Loop iteration 21: Skip unused parent-continuation allocation for tap mana costs (rejected)

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

Automated loop result on homelab (aarch64). Switch PHASE_MANA_TAP_PARENT_LEGACY, mechanism class allocation. Mechanism: In mana_abilities.rs::pay_mana_ability_cost_component, the fallback branch clones the cursor and pending ability and allocates two boxes to construct ManaAbilityCostParent. For an AbilityCost::Tap leaf, pay_mana_ability_cost_with_choices only calls tap_source and never reads that parent. Omit parent construction for precisely this leaf and pass None; preserve construction for every other cost. Invariant: The Tap arm does not consume the parent argument. Removing its unused snapshot must preserve cost payment, errors, event order, replacement pauses, unpaid suffixes, journal records and all three fingerprints. Every non-Tap cost retains its existing parent ownership.

gatepasseddetail
fmtyescargo fmt --all -- --check
buildyespwsh -NoProfile -File scripts/bench_phase.ps1 -Mode build -CargoProfile bench-fa
ir1kyesIr -0.12% within +/-1%, same-arm spread 0.0252%
ir4kNOIr -0.16% within +/-1%, same-arm spread 0.0265%

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