MTGBench improvement loop

Overview · Experiment index

Iteration 32: Bypass boolean population construction for typed quantity filters

state rejected — failed gate ir4k
switch PHASE_QUANTITY_TYPED_POPULATION_LEGACY · branch loop/it32 · base 4ec0b9ef1 · candidate 4a4611786 · took 57m 15s

Results

Verdict: TOO SMALL: only 0.00% fewer instructions, under the 0.3% floor. Cycles moved +2.12%, within this machine's noise (±4.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.00% instructions, same-arm spread 0.024%, equal work: yes, fingerprints match: yes-1% retain-0.3% kill0-0.00%
ArmRun 1 instructionsRun 2ActionsInstr / actioncontract msapply ms
legacy20,682,423,55920,677,561,8204,0005,169,9982,6592,329
optimized20,677,784,96720,682,199,3764,0005,169,9982,7502,709
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.12% — cycles-neutral (same-arm spread 4.16%)same within noise
IPC (instructions per cycle, higher is better)0.974 / 1.007same
backend stall / frontend stall (share of cycles)18.3% / 19.1%  ·  44.5% / 42.4%same
L1D / L2D refills per 1k instructions (cache misses)13.54 / 13.61  ·  11.85 / 11.55same
branch mispredicts per 1k instructions5.846 / 5.858same
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.10% fewer instructions, under the 0.3% floor. Cycles moved -0.41%, within this machine's noise (±4.8%): 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.10% instructions, same-arm spread 0.024%, equal work: yes, fingerprints match: yes
Gate FAILED: the harness refused this A/B (exit 2); see the write-up below. These counts are not a valid measurement.
-1% retain-0.3% kill0-0.10%
ArmRun 1 instructionsRun 2ActionsInstr / actioncontract msapply ms
legacy77,332,918,11377,314,020,61011,4186,772,06818,22911,855
optimized77,252,807,45177,240,479,74011,4186,765,33921,42914,664
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.41% — cycles-neutral (same-arm spread 4.82%)same within noise
IPC (instructions per cycle, higher is better)0.887 / 0.896same
backend stall / frontend stall (share of cycles)20.8% / 20.7%  ·  44.8% / 44.6%same
L1D / L2D refills per 1k instructions (cache misses)17.58 / 17.53  ·  13.85 / 13.90same
branch mispredicts per 1k instructions5.047 / 5.031same
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: 10 minexecutor: 29 minreviewer: 0 mingate fmt: 0 mingate build: 10 mingate ir1k: 1 mingate ir4k: 3 min
planner 10mexecutor 29mreviewer 0mgate fmt 0mgate build 10mgate ir1k 1mgate ir4k 3m
executor: 6,076,854 in / 13,217 out tokensplanner: 4,039,309 in / 12,895 out tokensreviewer: 23,090 in / 1,180 out tokens

Mechanism. At game/quantity.rs:3202, matching_object_ids_in_filter_universe sends a Typed leaf through disjunctive-branch construction, filter cloning, population anchoring and union deduplication. Add a Typed-only path that obtains candidates through the existing filter_zone_object_ids helper, applies matches_target_filter and preserves stable deduplication. Keep object_count_matching_candidate_ids authoritative for the final predicate and triggering-object exclusion.

Evidence. xn5.67, memo L4904, identifies the saved profile artifacts. uprof-xn565-20260923-owners-all.txt attributes 0.9% of process CPU to filter_population_anchor_ids; owners-alloc.txt attributes 0.5% to that allocator owner and separately lists matching_object_ids_in_filter_universe. These overlapping views must not be added. Typed-leaf coverage within these rows is unmeasured, but the proposed shortcut directly removes population preparation in that measured family.

Counter and kill threshold. Existing xn5.67 filter_population_anchor_ids CPU and allocation-owner rows. Expected instruction reduction: 0.4–0.9% per action at 4,000 actions, an unmeasured forecast likely to enter the marginal band. Instruction counts may under-report allocation savings.

Invariant. For a Typed leaf, the normalized algorithm has one predicate branch and the same explicit-zone population, or the battlefield default. Preserve the ordered, deduplicated matching IDs, phased-out exclusion and OtherThanTriggerObject handling. Permanent differential tests must compare complete ordered vectors and resolved counts with the legacy algorithm.

Agent steps

RoleHarness / modelTimeExitTokens in / outNote
plannercodex / gpt-6.1-sol10m 32s04,039,309 / 12,895
executorcodex / gpt-6-luna29m 38s06,076,854 / 13,217
reviewercodex / gpt-6.1-sol0m 59s023,090 / 1,180

Gates

GateResultExitDetail
fmtpass0cargo fmt --all -- --check
buildpass0pwsh -NoProfile -File scripts/bench_phase.ps1 -Mode build -CargoProfile bench-fast-inc -Label it32-build
ir1kpass0Ir -0.01% within +/-1%, same-arm spread 0.0235% | optimized 20,679,270,856 vs legacy 20,680,578,376 instructions; fingerprints match: True
ir4kFAIL2same-arm Ir spread 0.0509% exceeds 0.05%; no verdict | optimized 77,251,299,587 vs legacy 77,333,444,555 instructions; fingerprints match: True

Write-up: 2026-10-03 - Loop iteration 32: Bypass boolean population construction for typed quantity filters (rejected)

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

Automated loop result on homelab (aarch64). Switch PHASE_QUANTITY_TYPED_POPULATION_LEGACY, mechanism class allocation. Mechanism: At game/quantity.rs:3202, matching_object_ids_in_filter_universe sends a Typed leaf through disjunctive-branch construction, filter cloning, population anchoring and union deduplication. Add a Typed-only path that obtains candidates through the existing filter_zone_object_ids helper, applies matches_target_filter and preserves stable deduplication. Keep object_count_matching_candidate_ids authoritative for the final predicate and triggering-object exclusion. Invariant: For a Typed leaf, the normalized algorithm has one predicate branch and the same explicit-zone population, or the battlefield default. Preserve the ordered, deduplicated matching IDs, phased-out exclusion and OtherThanTriggerObject handling. Permanent differential tests must compare complete ordered vectors and resolved counts with the legacy algorithm.

gatepasseddetail
fmtyescargo fmt --all -- --check
buildyespwsh -NoProfile -File scripts/bench_phase.ps1 -Mode build -CargoProfile bench-fa
ir1kyesIr -0.01% within +/-1%, same-arm spread 0.0235%
ir4kNOsame-arm Ir spread 0.0509% exceeds 0.05%; no verdict

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