MTGBench improvement loop

Overview · Experiment index

Iteration 35: Stream spell-object IDs into priority candidate generation

state rejected — failed gate ir4k
switch PHASE_SPELL_POPULATION_STREAM_LEGACY · branch loop/it35 · base 4ec0b9ef1 · candidate 36719278a · took 1h 13m

Results

Verdict: TOO SMALL: only 0.04% fewer instructions, under the 0.3% floor. Cycles moved +2.04%, within this machine's noise (±1.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: 1,000 actions (screen) — -0.04% instructions, same-arm spread 0.012%, equal work: yes, fingerprints match: yes-1% retain-0.3% kill0-0.04%
ArmRun 1 instructionsRun 2ActionsInstr / actioncontract msapply ms
legacy22,093,588,39422,096,079,6654,0005,523,7092,5512,328
optimized22,087,325,01822,084,648,1154,0005,521,4972,7092,537
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.04% — cycles-neutral (same-arm spread 1.88%)same within noise
IPC (instructions per cycle, higher is better)0.982 / 0.999same
backend stall / frontend stall (share of cycles)18.0% / 18.4%  ·  43.4% / 42.5%same
L1D / L2D refills per 1k instructions (cache misses)12.73 / 12.70  ·  11.28 / 11.09same
branch mispredicts per 1k instructions6.216 / 5.994same
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.06% fewer instructions, under the 0.3% floor. Cycles moved +0.14%, within this machine's noise (±4.3%): 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.06% instructions, same-arm spread 0.017%, 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.06%
ArmRun 1 instructionsRun 2ActionsInstr / actioncontract msapply ms
legacy81,076,830,05481,076,647,90411,4187,100,78318,31312,034
optimized81,038,257,93581,024,532,50711,4187,096,81220,71313,600
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.14% — cycles-neutral (same-arm spread 4.31%)same within noise
IPC (instructions per cycle, higher is better)0.897 / 0.907same
backend stall / frontend stall (share of cycles)22.1% / 22.4%  ·  42.5% / 41.8%same
L1D / L2D refills per 1k instructions (cache misses)16.77 / 16.73  ·  13.53 / 13.45same
branch mispredicts per 1k instructions5.349 / 5.263same
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: 16 minexecutor: 40 minreviewer: 1 mingate fmt: 0 mingate build: 10 mingate ir1k: 1 mingate ir4k: 3 min
planner 16mexecutor 40mreviewer 1mgate fmt 0mgate build 10mgate ir1k 1mgate ir4k 3m
executor: 5,565,090 in / 16,651 out tokensplanner: 3,926,731 in / 12,188 out tokensreviewer: 24,448 in / 1,419 out tokens

Mechanism. At casting.rs::spell_objects_available_to_cast and ai_support/candidates.rs::priority_actions_with_probe, replace the temporary aggregate Vec<ObjectId> with a private visitor that delivers IDs directly to the existing candidate-building body. Preserve every zone producer, restriction predicate, duplicate and emission order. Keep the public Vec-returning API unchanged.

Evidence. xn5.67, docs/stage0-decision-memo.md:L4904, names the reference capture. Its bench/reports/uprof-xn565-20260923-owners-all.txt attributes 1.6% of process CPU to spell_objects_available_to_cast; owners-alloc.txt attributes 0.9% to its allocation family. These are historical family bounds, not measurements of the removable aggregate vector; later retained changes may have reduced them.

Counter and kill threshold. Existing xn5.67 spell_objects_available_to_cast owner rows: 1.6% CPU overall, 0.9% allocation family, nested rather than additive. Expected instruction reduction: 0.3–0.7% per action at 4,000 actions, an unmeasured forecast likely to be marginal. The loop's existing instruction and fingerprint gates decide it.

Invariant. The visitor must emit exactly the legacy ID sequence, including duplicates, and invoke castability and payment-mode checks equally often in the same order. Add a permanent differential regression comparing emitted IDs and complete priority candidates across hand, commander, overlapping graveyard/exile permissions, temporary prohibitions, missing objects and split second; include positive permission cases and compare all fingerprint families.

Agent steps

RoleHarness / modelTimeExitTokens in / outNote
plannercodex / gpt-6.1-sol16m 1s03,926,731 / 12,188
executorcodex / gpt-6-luna40m 53s05,565,090 / 16,651
reviewercodex / gpt-6.1-sol1m 28s024,448 / 1,419

Gates

GateResultExitDetail
fmtpass0cargo fmt --all -- --check
buildpass0pwsh -NoProfile -File scripts/bench_phase.ps1 -Mode build -CargoProfile bench-fast-inc -Label it35-build
ir1kpass0Ir -0.04% within +/-1%, same-arm spread 0.0215% | optimized 22,086,364,899 vs legacy 22,096,002,467 instructions; fingerprints match: True
ir4kFAIL0Ir -0.06% within +/-1%, same-arm spread 0.0199% | optimized 81,030,963,163 vs legacy 81,082,085,426 instructions; fingerprints match: True

Write-up: 2026-10-03 - Loop iteration 35: Stream spell-object IDs into priority candidate generation (rejected)

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

Automated loop result on homelab (aarch64). Switch PHASE_SPELL_POPULATION_STREAM_LEGACY, mechanism class allocation. Mechanism: At casting.rs::spell_objects_available_to_cast and ai_support/candidates.rs::priority_actions_with_probe, replace the temporary aggregate Vec<ObjectId> with a private visitor that delivers IDs directly to the existing candidate-building body. Preserve every zone producer, restriction predicate, duplicate and emission order. Keep the public Vec-returning API unchanged. Invariant: The visitor must emit exactly the legacy ID sequence, including duplicates, and invoke castability and payment-mode checks equally often in the same order. Add a permanent differential regression comparing emitted IDs and complete priority candidates across hand, commander, overlapping graveyard/exile permissions, temporary prohibitions, missing objects and split second; include positive permission cases and compare all fingerprint families.

gatepasseddetail
fmtyescargo fmt --all -- --check
buildyespwsh -NoProfile -File scripts/bench_phase.ps1 -Mode build -CargoProfile bench-fa
ir1kyesIr -0.04% within +/-1%, same-arm spread 0.0215%
ir4kNOIr -0.06% within +/-1%, same-arm spread 0.0199%

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