MTGBench improvement loop

Overview · Experiment index

Iteration 36: Evaluate simple filter properties before constructing source context

state confirm-pending — gate ir4k: marginal instruction reduction (compute); the workstation wall-clock decides
switch PHASE_CONTEXT_FREE_FILTER_PROPERTIES_LEGACY · branch loop/it36 · base 4ec0b9ef1 · candidate cc12c456d · took 2h 23m

Results

Verdict: TOO SMALL: only 0.06% fewer instructions, under the 0.3% floor. Cycles moved -6.40%, 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.06% instructions, same-arm spread 0.015%, equal work: yes, fingerprints match: yes-1% retain-0.3% kill0-0.06%
ArmRun 1 instructionsRun 2ActionsInstr / actioncontract msapply ms
legacy21,785,685,49021,788,902,2354,0005,446,8232,6302,570
optimized21,776,190,36721,773,094,5184,0005,443,6613,0333,201
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-6.40% — cycles-neutral (same-arm spread 10.20%)same within noise
IPC (instructions per cycle, higher is better)0.966 / 0.937same
backend stall / frontend stall (share of cycles)18.1% / 15.4%  ·  45.0% / 48.7%more waiting
L1D / L2D refills per 1k instructions (cache misses)12.94 / 12.93  ·  11.25 / 11.13same
branch mispredicts per 1k instructions5.631 / 5.675same
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.34% fewer instructions, between 0.3% and 1%. It is sent to the PC wall-clock check instead of being kept outright. Cycles moved -1.90%, within this machine's noise (±2.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) — -0.34% instructions, same-arm spread 0.038%, equal work: yes, fingerprints match: yes-1% retain-0.3% kill0-0.34%
ArmRun 1 instructionsRun 2ActionsInstr / actioncontract msapply ms
legacy78,669,004,76778,660,925,35311,4186,889,55718,85112,438
optimized78,413,609,42378,384,160,04411,4186,866,25419,84112,998
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.90% — cycles-neutral (same-arm spread 2.56%)same within noise
IPC (instructions per cycle, higher is better)0.869 / 0.854same
backend stall / frontend stall (share of cycles)17.4% / 17.7%  ·  49.4% / 49.6%same
L1D / L2D refills per 1k instructions (cache misses)17.33 / 17.29  ·  13.62 / 13.71same
branch mispredicts per 1k instructions4.943 / 5.060same
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/it36-parity-20261003-151210-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: 15 minexecutor: 82 minreviewer: 0 mingate fmt: 0 mingate build: 9 mingate ir1k: 1 mingate ir4k: 3 mingate check: 6 mingate focused: 16 mingate parity: 5 min
planner 15mexecutor 82mreviewer 0mgate fmt 0mgate build 9mgate ir1k 1mgate ir4k 3mgate check 6mgate focused 16mgate parity 5m
executor: 16,758,767 in / 26,876 out tokensplanner: 4,088,809 in / 14,529 out tokensreviewer: 25,178 in / 793 out tokens

Mechanism. In game/filter.rs:3328, nonempty TypedFilter properties construct SourceContext even when their predicates read only the matched object. Extract a small context-free predicate helper from matches_filter_prop and construct the existing source context lazily, only when an unsupported property needs it. Preserve property order and short-circuiting.

Evidence. xn5.67, docs/stage0-decision-memo.md:L4904, references bench/reports/uprof-xn565-20260923-owners-all.txt: source_context_from_filter_with_family owns 1.1% of process CPU. This is a measured family bound, not an isolated removable fraction. The profile predates the loop's empty-properties and source-payload borrowing changes; this candidate addresses nonempty properties that need no source context.

Counter and kill threshold. Existing profile row: source_context_from_filter_with_family, 1.1% nearest-owner CPU. Existing source_context_built counters can diagnose avoided construction. Expected instruction reduction: 0.4–0.9% per action at 4,000 actions; hypothesis, with the loop's normal tiers deciding.

Invariant. Each supported predicate must return exactly its current canonical result without consulting SourceContext. Source-dependent and unfamiliar properties retain the original evaluator and exact live/latched source authority. Permanent differential tests must compare both paths for simple properties, mixed property lists, early rejection, dynamic thresholds, missing sources, and recycled source identities.

Agent steps

RoleHarness / modelTimeExitTokens in / outNote
plannercodex / gpt-6.1-sol15m 41s04,088,809 / 14,529
executorcodex / gpt-6-luna1h 22m016,758,767 / 26,876
reviewercodex / gpt-6.1-sol0m 44s025,178 / 793

Gates

GateResultExitDetail
fmtpass0cargo fmt --all -- --check
buildpass0pwsh -NoProfile -File scripts/bench_phase.ps1 -Mode build -CargoProfile bench-fast-inc -Label it36-build
ir1kpass0Ir -0.06% within +/-1%, same-arm spread 0.0149% | optimized 21,774,289,841 vs legacy 21,787,837,325 instructions; fingerprints match: True
ir4kFAIL0Ir -0.34% within +/-1%, same-arm spread 0.0376% | optimized 78,395,597,929 vs legacy 78,662,151,765 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 it36-parity

Write-up: 2026-10-03 - Loop iteration 36: Evaluate simple filter properties before constructing source context (confirm-pending)

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

Automated loop result on homelab (aarch64). Switch PHASE_CONTEXT_FREE_FILTER_PROPERTIES_LEGACY, mechanism class compute. Mechanism: In game/filter.rs:3328, nonempty TypedFilter properties construct SourceContext even when their predicates read only the matched object. Extract a small context-free predicate helper from matches_filter_prop and construct the existing source context lazily, only when an unsupported property needs it. Preserve property order and short-circuiting. Invariant: Each supported predicate must return exactly its current canonical result without consulting SourceContext. Source-dependent and unfamiliar properties retain the original evaluator and exact live/latched source authority. Permanent differential tests must compare both paths for simple properties, mixed property lists, early rejection, dynamic thresholds, missing sources, and recycled source identities.

gatepasseddetail
fmtyescargo fmt --all -- --check
buildyespwsh -NoProfile -File scripts/bench_phase.ps1 -Mode build -CargoProfile bench-fa
ir1kyesIr -0.06% within +/-1%, same-arm spread 0.0149%
ir4kmarginal: workstation checkIr -0.34% within +/-1%, same-arm spread 0.0376%
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