MTGBench improvement loop

Overview · Experiment index

Iteration 18: Skip source-context construction for empty typed-filter properties

state confirm-pending — gate ir4k: marginal instruction reduction (compute); the workstation wall-clock decides
switch PHASE_EMPTY_FILTER_PROPERTIES_LEGACY · branch loop/it18 · base 4ec0b9ef1 · candidate ee5c123e6 · took 1h 24m

Results

Verdict: TOO SMALL: only 0.07% fewer instructions, under the 0.3% floor. Cycles moved -4.02%, within this machine's noise (±10.2%): 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.07% instructions, same-arm spread 0.009%, equal work: yes, fingerprints match: yes-1% retain-0.3% kill0-0.07%
ArmRun 1 instructionsRun 2ActionsInstr / actioncontract msapply ms
legacy21,781,414,33621,783,433,4894,0005,445,6062,8652,810
optimized21,767,024,08821,766,399,4524,0005,441,6782,6092,587
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-4.02% — cycles-neutral (same-arm spread 10.25%)same within noise
IPC (instructions per cycle, higher is better)1.005 / 0.995same
backend stall / frontend stall (share of cycles)17.3% / 18.3%  ·  43.9% / 42.9%less waiting
L1D / L2D refills per 1k instructions (cache misses)12.84 / 12.94  ·  11.12 / 11.33same
branch mispredicts per 1k instructions5.683 / 5.720same
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: MARGINAL: 0.86% fewer instructions, between 0.3% and 1%. It is sent to the PC wall-clock check instead of being kept outright. Cycles moved -1.00%, within this machine's noise (±1.2%): 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.86% instructions, same-arm spread 0.006%, equal work: yes, fingerprints match: yes-1% retain-0.3% kill0-0.86%
ArmRun 1 instructionsRun 2ActionsInstr / actioncontract msapply ms
legacy78,428,179,09178,423,299,52211,4186,868,60619,74912,679
optimized77,748,659,69277,746,825,65311,4186,809,22619,54612,660
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.00% — cycles-neutral (same-arm spread 1.22%)same within noise
IPC (instructions per cycle, higher is better)0.886 / 0.888same
backend stall / frontend stall (share of cycles)18.1% / 18.6%  ·  47.3% / 46.6%same
L1D / L2D refills per 1k instructions (cache misses)17.43 / 17.32  ·  13.92 / 13.85same
branch mispredicts per 1k instructions5.152 / 5.144same
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/it18-parity-20261002-021353-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: 7 minexecutor: 32 minreviewer: 0 mingate fmt: 0 mingate build: 8 mingate ir1k: 1 mingate ir4k: 3 mingate check: 6 mingate focused: 16 mingate parity: 5 min
planner 7mexecutor 32mreviewer 0mgate fmt 0mgate build 8mgate ir1k 1mgate ir4k 3mgate check 6mgate focused 16mgate parity 5m
executor: 7,136,401 in / 12,895 out tokensplanner: 2,362,724 in / 8,259 out tokensreviewer: 19,839 in / 614 out tokens

Mechanism. In game/filter.rs:3341, the Typed filter arm constructs SourceContext even when properties is empty. After the existing type and controller checks succeed, return true for an empty property list. Keep every nonempty property evaluation unchanged.

Evidence. xn5.67, docs/stage0-decision-memo.md:4904, is the latest indexed CPU profile. Its owners report attributes 1.1% of process CPU to source_context_from_filter_with_family and 2.1% to filter_inner_for_object. xn5.50 at memo line 3603 already removed eager LKI snapshots; this targets the residual context construction visible in the current source. The empty-property fraction is unmeasured, so 1.1% is a family ceiling, not a removable-share measurement. Profile artifact: bench/reports/uprof-xn565-20260923-owners-all.txt.

Counter and kill threshold. Existing source_context_built counters and xn5.67's 1.1% source-context owner row bound the opportunity. Expected instruction reduction: 0.4–0.9% per action at 4,000 actions, with substantial uncertainty about empty-property coverage; likely marginal.

Invariant. An empty property list is an empty conjunction and evaluates to true. Preserve object existence, phasing, type and controller checks before returning. Add a permanent differential regression covering successful and failed type/controller gates, missing and phased-out objects, nested filters, and a nonempty source-relative property that must still construct its context.

Agent steps

RoleHarness / modelTimeExitTokens in / outNote
plannercodex / gpt-6.1-sol7m 36s02,362,724 / 8,259
executorcodex / gpt-6-luna32m 57s07,136,401 / 12,895
reviewercodex / gpt-6.1-sol0m 33s019,839 / 614

Gates

GateResultExitDetail
fmtpass0cargo fmt --all -- --check
buildpass0pwsh -NoProfile -File scripts/bench_phase.ps1 -Mode build -CargoProfile bench-fast-inc -Label it18-build
ir1kpass0Ir -0.07% within +/-1%, same-arm spread 0.0093% | optimized 21,766,590,045 vs legacy 21,782,337,769 instructions; fingerprints match: True
ir4kFAIL0Ir -0.87% within +/-1%, same-arm spread 0.0126% | optimized 77,747,654,189 vs legacy 78,428,220,447 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 it18-parity

Write-up: 2026-10-02 - Loop iteration 18: Skip source-context construction for empty typed-filter properties (confirm-pending)

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

Automated loop result on homelab (aarch64). Switch PHASE_EMPTY_FILTER_PROPERTIES_LEGACY, mechanism class compute. Mechanism: In game/filter.rs:3341, the Typed filter arm constructs SourceContext even when properties is empty. After the existing type and controller checks succeed, return true for an empty property list. Keep every nonempty property evaluation unchanged. Invariant: An empty property list is an empty conjunction and evaluates to true. Preserve object existence, phasing, type and controller checks before returning. Add a permanent differential regression covering successful and failed type/controller gates, missing and phased-out objects, nested filters, and a nonempty source-relative property that must still construct its context.

gatepasseddetail
fmtyescargo fmt --all -- --check
buildyespwsh -NoProfile -File scripts/bench_phase.ps1 -Mode build -CargoProfile bench-fa
ir1kyesIr -0.07% within +/-1%, same-arm spread 0.0093%
ir4kmarginal: workstation checkIr -0.87% within +/-1%, same-arm spread 0.0126%
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:15 · read-only · refreshes every 30 s