MTGBench improvement loop

Overview · Experiment index

Iteration 16: Screen protection grants before evaluating static conditions

state retained — instruction-count retained; awaiting workstation wall-clock confirmation
switch PHASE_PROTECTION_CONDITION_PREFILTER_LEGACY · branch loop/it16 · base 4ec0b9ef1 · candidate eabd48c40 · took 1h 47m

Results

Verdict: TOO SMALL: only 0.04% fewer instructions, under the 0.3% floor. Cycles moved +1.86%, within this machine's noise (±3.0%): 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.005%, equal work: yes, fingerprints match: yes-1% retain-0.3% kill0-0.04%
ArmRun 1 instructionsRun 2ActionsInstr / actioncontract msapply ms
legacy21,505,856,82221,504,810,0364,0005,376,3332,2442,164
optimized21,497,861,07021,497,708,9434,0005,374,4462,6012,306
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.86% — cycles-neutral (same-arm spread 3.00%)same within noise
IPC (instructions per cycle, higher is better)1.023 / 1.044same
backend stall / frontend stall (share of cycles)17.3% / 18.7%  ·  43.4% / 41.0%less waiting
L1D / L2D refills per 1k instructions (cache misses)12.90 / 12.98  ·  11.27 / 11.06same
branch mispredicts per 1k instructions5.584 / 5.669same
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: GOOD: 1.51% fewer instructions, above the 1% bar. Cycles moved -3.90%, within this machine's noise (±3.6%): 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) — -1.51% instructions, same-arm spread 0.017%, equal work: yes, fingerprints match: yes-1% retain-0.3% kill0-1.51%
ArmRun 1 instructionsRun 2ActionsInstr / actioncontract msapply ms
legacy76,531,641,39976,521,546,62011,4186,702,27718,01912,185
optimized75,363,338,36975,375,820,93611,4186,600,94419,30512,596
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.90% — cycles-neutral (same-arm spread 3.56%)same within noise
IPC (instructions per cycle, higher is better)0.914 / 0.900same
backend stall / frontend stall (share of cycles)22.0% / 19.9%  ·  42.2% / 45.0%more waiting
L1D / L2D refills per 1k instructions (cache misses)17.55 / 17.46  ·  14.09 / 13.87same
branch mispredicts per 1k instructions5.033 / 5.070same
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.
Gate: parity (7 seeds, decks rotate per seed)
coverage: 253 distinct cards cast, 35 action kinds, 41 decision kinds, 59 event kinds, max battlefield 35, max stack 5
coverage: 143 of 257 engine counters were nonzero somewhere (unioned over 7 seeds; decks rotate per seed)
parity: 1 matched, 6 matched with an engine rejection in both arms, 0 diverged, 0 arm failures; summary /data/mtgbench/edh-play/bench/reports/it16-parity-20261001-232858-parity.json
9 games ended early on an engine rejection (counted over both arms). A rejection that happens identically in both arms is a match, but those games never reach their late game, so late-game behaviour of those decks is not exercised.

Where the time went

planner: 10 minexecutor: 2 minreviewer: 0 mingate fmt: 0 mingate build: 9 mingate ir1k: 1 mingate ir4k: 3 mingate check: 6 mingate focused: 16 mingate parity: 5 minnot attributed: 50 min
planner 10mexecutor 2mreviewer 0mgate fmt 0mgate build 9mgate ir1k 1mgate ir4k 3mgate check 6mgate focused 16mgate parity 5mnot attributed 50m
executor: 1,010,592 in / 3,568 out tokensplanner: 4,063,056 in / 12,029 out tokensreviewer: 21,989 in / 1,211 out tokens

Mechanism. The loop-it11 prefilter rejects irrelevant modifications after battlefield_active_statics has already evaluated each definition's condition. Add a protection-specific enumeration path that checks mode and modification shape before applying the existing functioning-static gates. Leave attachment matching and protection exemptions unchanged.

Evidence. xn5.29, docs/stage0-decision-memo.md:2536, identifies unattached-equipment checks as a measured SBA cost. More recently, bench/reports/it11-ir4k-20261001-140827-optimized.json records 450.907 ms in that family, 1.443% of contract+apply, after the previous prefilter. Its validated instruction A/B saved 0.715%. Inspection of loop/it11 confirms condition evaluation still precedes its discriminator. The remaining condition-evaluation fraction is unmeasured.

Counter and kill threshold. Existing sba_family_unattached_equipment_ns bounds a principal caller; attachment checks elsewhere also use this path. Expected additional instruction reduction: 0.3–0.8% per action at 4,000 actions, an unmeasured estimate. The loop's existing tiers decide retention.

Invariant. Definitions without a Continuous AddKeyword Protection modification cannot contribute to this protection-grant loop. Surviving definitions must pass precisely the existing phased-out, zone, Room and condition gates, in their original order. Preserve original definition/modification indices, printed protection, transient grants, exemption riders and the live-keyword fallback. Permanently compare both arms across conditional grants, irrelevant conditional statics, phased-out sources, chosen colors and competing exempt/nonexempt grants.

Agent steps

RoleHarness / modelTimeExitTokens in / outNote
plannercodex / gpt-6.1-sol10m 4s04,063,056 / 12,029
executorcodex / gpt-6-luna1388h 20m /
executorcodex / gpt-6-luna2m 59s01,010,592 / 3,568
reviewercodex / gpt-6.1-sol0m 57s021,989 / 1,211

Gates

GateResultExitDetail
fmtpass0cargo fmt --all -- --check
buildpass0pwsh -NoProfile -File scripts/bench_phase.ps1 -Mode build -CargoProfile bench-fast-inc -Label it16-build
ir1kpass0Ir -0.04% within +/-1%, same-arm spread 0.0161% | optimized 21,496,658,335 vs legacy 21,505,911,113 instructions; fingerprints match: True
ir4kpass0Ir -1.51% (threshold -1%), same-arm spread 0.0184% | optimized 75,367,037,128 vs legacy 76,524,483,619 instructions; fingerprints match: True
checkpass0
focusedpass0
paritypass0pwsh -NoProfile -File scripts/bench_phase.ps1 -Mode parity -Seeds 1,2,3,5,7,11,13 -Actions 1000 -CargoProfile bench-fast-inc -Label it16-parity

Write-up: 2026-10-01 - Loop iteration 16: Screen protection grants before evaluating static conditions (retained)

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

Automated loop result on homelab (aarch64). Switch PHASE_PROTECTION_CONDITION_PREFILTER_LEGACY, mechanism class compute. Mechanism: The loop-it11 prefilter rejects irrelevant modifications after battlefield_active_statics has already evaluated each definition's condition. Add a protection-specific enumeration path that checks mode and modification shape before applying the existing functioning-static gates. Leave attachment matching and protection exemptions unchanged. Invariant: Definitions without a Continuous AddKeyword Protection modification cannot contribute to this protection-grant loop. Surviving definitions must pass precisely the existing phased-out, zone, Room and condition gates, in their original order. Preserve original definition/modification indices, printed protection, transient grants, exemption riders and the live-keyword fallback. Permanently compare both arms across conditional grants, irrelevant conditional statics, phased-out sources, chosen colors and competing exempt/nonexempt grants.

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.0161%
ir4kyesIr -1.51% (threshold -1%), same-arm spread 0.0184%
checkyes
focusedyes
parityyespwsh -NoProfile -File scripts/bench_phase.ps1 -Mode parity -Seeds 1,2,3,5,7,11,1

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