MTGBench improvement loop

Overview · Experiment index

Iteration 49: Prefilter attachment restrictions before static-condition evaluation

state rejected — failed gate ir4k
switch PHASE_ATTACHMENT_RESTRICTION_PREFILTER_LEGACY · branch loop/it49 · base 4ec0b9ef1 · candidate 3f734fb25 · took 48m 38s

Results

Verdict: TOO SMALL: only 0.01% fewer instructions, under the 0.3% floor. Cycles moved -0.82%, within this machine's noise (±8.1%): 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.01% instructions, same-arm spread 0.017%, equal work: yes, fingerprints match: yes-1% retain-0.3% kill0-0.01%
ArmRun 1 instructionsRun 2ActionsInstr / actioncontract msapply ms
legacy21,785,258,25321,788,254,6684,0005,446,6892,5322,357
optimized21,787,411,73121,783,778,0514,0005,446,3992,6132,542
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.82% — cycles-neutral (same-arm spread 8.13%)same within noise
IPC (instructions per cycle, higher is better)1.004 / 1.009same
backend stall / frontend stall (share of cycles)18.3% / 16.9%  ·  42.7% / 44.1%more waiting
L1D / L2D refills per 1k instructions (cache misses)12.83 / 12.84  ·  11.22 / 11.19same
branch mispredicts per 1k instructions5.597 / 5.763same
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: NO GAIN: 0.01% MORE instructions. Cycles moved +0.04%, within this machine's noise (±4.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: 4,000 actions (verdict) — +0.01% instructions, same-arm spread 0.029%, 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.01%
ArmRun 1 instructionsRun 2ActionsInstr / actioncontract msapply ms
legacy78,435,095,82878,426,213,62111,4186,869,03618,96312,722
optimized78,450,200,09478,427,527,88111,4186,869,75521,33113,710
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.04% — cycles-neutral (same-arm spread 4.04%)same within noise
IPC (instructions per cycle, higher is better)0.867 / 0.876same
backend stall / frontend stall (share of cycles)18.8% / 19.9%  ·  47.4% / 45.6%less waiting
L1D / L2D refills per 1k instructions (cache misses)17.30 / 17.30  ·  13.98 / 13.99same
branch mispredicts per 1k instructions5.351 / 5.302same
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: 11 minexecutor: 20 minreviewer: 0 mingate fmt: 0 mingate build: 9 mingate ir1k: 1 mingate ir4k: 3 min
planner 11mexecutor 20mreviewer 0mgate fmt 0mgate build 9mgate ir1k 1mgate ir4k 3m
executor: 4,374,145 in / 9,658 out tokensplanner: 5,137,041 in / 13,527 out tokensreviewer: 20,345 in / 951 out tokens

Mechanism. In game/effects/attach.rs:1917, attachment_satisfies_restrictions evaluates functioning gates and conditions for every attachment static before selecting StaticMode::AttachmentRestriction. Select that mode first, then apply the existing authoritative functioning predicate and host-filter check.

Evidence. xn5.29, docs/stage0-decision-memo.md:2536, measured unattached-equipment SBA work as a material family. The newer saved report bench/reports/it48-ir4k-20261004-083350-optimized.json records sba_family_unattached_equipment_ns=627581487 against 34217 ms contract+apply, or 1.834%. Its verdict records matching fingerprints and equal work. This is an enclosing diagnostic bound; restriction-condition evaluation has no exclusive timer. The previous protection prefilters targeted protection-grant discovery, a different consumer.

Counter and kill threshold. Existing sba_family_unattached_equipment_ns bounds the main consumer at 1.834% of contract+apply in the saved 4,000-action report. Expected instruction reduction: 0.3–0.7% per action, an unmeasured estimate likely to be marginal. The unrelated-condition fraction is unknown.

Invariant. Unrelated static modes cannot impose an attachment restriction. Matching definitions must retain identical phasing, zone, Room-door, condition and host-filter gates, including when the supplied attachment is an entrant projection rather than the stored object. Preserve the attachment verdict, emitted events and all three fingerprints.

Agent steps

RoleHarness / modelTimeExitTokens in / outNote
plannercodex / gpt-6.1-sol11m 58s05,137,041 / 13,527
executorcodex / gpt-6-luna20m 55s04,374,145 / 9,658
reviewercodex / gpt-6.1-sol0m 44s020,345 / 951

Gates

GateResultExitDetail
fmtpass0cargo fmt --all -- --check
buildpass0pwsh -NoProfile -File scripts/bench_phase.ps1 -Mode build -CargoProfile bench-fast-inc -Label it49-build
ir1kpass0Ir -+0.00% within +/-1%, same-arm spread 0.0245% | optimized 21,785,095,064 vs legacy 21,785,477,464 instructions; fingerprints match: True
ir4kFAIL0Ir +0.02% within +/-1%, same-arm spread 0.0289% | optimized 78,438,638,516 vs legacy 78,426,106,991 instructions; fingerprints match: True

Write-up: 2026-10-04 - Loop iteration 49: Prefilter attachment restrictions before static-condition evaluation (rejected)

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

Automated loop result on homelab (aarch64). Switch PHASE_ATTACHMENT_RESTRICTION_PREFILTER_LEGACY, mechanism class compute. Mechanism: In game/effects/attach.rs:1917, attachment_satisfies_restrictions evaluates functioning gates and conditions for every attachment static before selecting StaticMode::AttachmentRestriction. Select that mode first, then apply the existing authoritative functioning predicate and host-filter check. Invariant: Unrelated static modes cannot impose an attachment restriction. Matching definitions must retain identical phasing, zone, Room-door, condition and host-filter gates, including when the supplied attachment is an entrant projection rather than the stored object. Preserve the attachment verdict, emitted events and all three fingerprints.

gatepasseddetail
fmtyescargo fmt --all -- --check
buildyespwsh -NoProfile -File scripts/bench_phase.ps1 -Mode build -CargoProfile bench-fa
ir1kyesIr -+0.00% within +/-1%, same-arm spread 0.0245%
ir4kNOIr +0.02% within +/-1%, same-arm spread 0.0289%

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