PHASE_TRIGGER_INDEX_BORROW_LEGACY · branch loop/it12 · base 4ec0b9ef1 · candidate 3821cad8d · took 3h 41m| Arm | Run 1 instructions | Run 2 | Actions | Instr / action | contract ms | apply ms |
|---|---|---|---|---|---|---|
| legacy | 21,782,201,095 | 21,785,284,291 | 4,000 | 5,445,936 | 2,417 | 2,272 |
| optimized | 21,738,927,342 | 21,735,805,862 | 4,000 | 5,434,342 | 2,630 | 2,468 |
perf: indicative only, not a clean timing.| Hardware counters (optimized / legacy) | Value | Reading |
|---|---|---|
| cycles, minimum of the repeats | -2.56% — cycles-neutral (same-arm spread 6.92%) | same within noise |
| IPC (instructions per cycle, higher is better) | 1.026 / 1.009 | same |
| backend stall / frontend stall (share of cycles) | 16.3% / 16.3% · 44.1% / 44.1% | same |
| L1D / L2D refills per 1k instructions (cache misses) | 12.82 / 12.86 · 10.90 / 10.90 | same |
| branch mispredicts per 1k instructions | 5.630 / 5.407 | same |
| Arm | Run 1 instructions | Run 2 | Actions | Instr / action | contract ms | apply ms |
|---|---|---|---|---|---|---|
| legacy | 78,430,298,062 | 78,425,270,638 | 11,418 | 6,868,785 | 19,302 | 13,055 |
| optimized | 78,022,092,759 | 78,019,557,817 | 11,418 | 6,833,143 | 18,966 | 12,122 |
perf: indicative only, not a clean timing.| Hardware counters (optimized / legacy) | Value | Reading |
|---|---|---|
| cycles, minimum of the repeats | -0.57% — cycles-neutral (same-arm spread 3.07%) | same within noise |
| IPC (instructions per cycle, higher is better) | 0.910 / 0.903 | same |
| backend stall / frontend stall (share of cycles) | 22.1% / 20.3% · 41.9% / 44.1% | more waiting |
| L1D / L2D refills per 1k instructions (cache misses) | 17.29 / 17.29 · 13.55 / 13.64 | same |
| branch mispredicts per 1k instructions | 5.086 / 5.328 | same |
Mechanism. At game/trigger_index.rs:1136, rebuild_from_battlefield deep-clones each materialized TriggerDefinition into a SmallVec before classifying it. Add a private registration helper accepting borrowed definitions and use it during rebuilding and reindex_object_triggers. Preserve the public slice-based add API.
Evidence. docs/stage0-decision-memo.md:L4904, xn5.67, attributes 0.80% inclusive process CPU to TriggerIndex::rebuild_from_battlefield. This is the narrowest measured envelope among these candidates; the clone-only fraction is unmeasured. xn5.71 at L5434 retained sharing of captured TriggerSourceContext entries, which is a separate clone site and provides no additional credit here. The profile predates subsequent retained changes.
Counter and kill threshold. Existing xn5.67 profile row: TriggerIndex::rebuild_from_battlefield, 0.80% inclusive CPU. Expected whole-engine instruction reduction per action: 0.3–0.6%, an uncertain forecast. Copy and allocation savings may appear marginal in instruction counts.
Invariant. Classification reads definitions without modifying them. Borrowing must preserve registration order, bucket contents, duplicate suppression, synthetic-keyword routing and materialized occurrence identities. Permanently compare complete indices and ordered event candidates between both implementations, including granted/removed triggers, phased-out objects and rebuilding after deserialization.
| Role | Harness / model | Time | Exit | Tokens in / out | Note |
|---|---|---|---|---|---|
| planner | codex / gpt-6.1-sol | 1396h 47m | / | ||
| planner | codex / gpt-6.1-sol | 13m 0s | 0 | 3,965,785 / 14,361 | |
| executor | codex / gpt-6-luna | 32m 52s | 0 | 4,331,363 / 12,309 | |
| reviewer | codex / gpt-6.1-sol | 0m 35s | 0 | 21,059 / 660 |
| Gate | Result | Exit | Detail |
|---|---|---|---|
| fmt | pass | 0 | cargo fmt --all -- --check |
| build | pass | 0 | pwsh -NoProfile -File scripts/bench_phase.ps1 -Mode build -CargoProfile bench-fast-inc -Label it12-build |
| ir1k | pass | 0 | Ir -0.22% within +/-1%, same-arm spread 0.0144% | optimized 21,736,900,434 vs legacy 21,784,143,963 instructions; fingerprints match: True |
| ir4k | FAIL | 0 | Ir -0.51% within +/-1%, same-arm spread 0.0463% | optimized 78,032,438,267 vs legacy 78,431,012,655 instructions; fingerprints match: True |
| check | pass | 0 | |
| focused | pass | 0 | |
| parity | pass | 0 | pwsh -NoProfile -File scripts/bench_phase.ps1 -Mode parity -Seeds 1,2,3,5,7,11,13 -Actions 1000 -CargoProfile bench-fast-inc -Label it12-parity |
Status: unknown (loop, instruction-count gate; wall-clock not yet confirmed)
Automated loop result on homelab (aarch64). Switch PHASE_TRIGGER_INDEX_BORROW_LEGACY, mechanism class copy. Mechanism: At game/trigger_index.rs:1136, rebuild_from_battlefield deep-clones each materialized TriggerDefinition into a SmallVec before classifying it. Add a private registration helper accepting borrowed definitions and use it during rebuilding and reindex_object_triggers. Preserve the public slice-based add API. Invariant: Classification reads definitions without modifying them. Borrowing must preserve registration order, bucket contents, duplicate suppression, synthetic-keyword routing and materialized occurrence identities. Permanently compare complete indices and ordered event candidates between both implementations, including granted/removed triggers, phased-out objects and rebuilding after deserialization.
| gate | passed | detail |
|---|---|---|
| fmt | yes | cargo fmt --all -- --check |
| build | yes | pwsh -NoProfile -File scripts/bench_phase.ps1 -Mode build -CargoProfile bench-fa |
| ir1k | yes | Ir -0.22% within +/-1%, same-arm spread 0.0144% |
| ir4k | marginal: workstation check | Ir -0.51% within +/-1%, same-arm spread 0.0463% |
| check | yes | |
| focused | yes | |
| parity | yes | pwsh -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:16 · read-only · refreshes every 30 s