Game: short-circuit pipeline state enumeration once wanted hashes are found #2575

Open
github-bot wants to merge 1 commit from github-bot/gh-2575 into main AGit
Owner

@⁠reeledMarek on GitHub · 2026-11-25 16:08 UTC · original
reeledMarek:fix/game-pipelines-perf → main · +109 −29 · 1 files · 1 commits · open

Summary

Short-circuits pipeline state enumeration in victory_game::pipelines as soon as all wanted hashes are resolved, instead of always exhausting the entire search space.

Changes

  • Skip name_from_registers, depth_space, and raster_space in Named::find when their corresponding want sets are already empty.
  • Propagate std::ops::ControlFlow<()> from raster_space, depth_space, depth_from_registers, and blend_from_registers so Named::find and name_from_registers stop immediately once every wanted hash (or the current record's target hash) has been matched.
  • Updated existing unit tests and added raster_space_short_circuits_on_break to verify early termination.

Scope

Trimmed to only the ControlFlow early exits per triage feedback; candidate generation in blend_from_registers and raster_space is unchanged.

Verification

  • cargo test -p victory-game --locked
  • cargo clippy -p victory-game --all-targets --target x86_64-pc-windows-msvc --locked -- -D warnings
  • cargo test -p xtask --locked
**@⁠reeledMarek** on GitHub · 2026-11-25 16:08 UTC · [original](https://github.com/Marvisak/VIctory/pull/2575) `reeledMarek:fix/game-pipelines-perf` → `main` · +109 −29 · 1 files · 1 commits · open ### Summary Short-circuits pipeline state enumeration in `victory_game::pipelines` as soon as all wanted hashes are resolved, instead of always exhausting the entire search space. ### Changes - Skip `name_from_registers`, `depth_space`, and `raster_space` in `Named::find` when their corresponding `want` sets are already empty. - Propagate `std::ops::ControlFlow<()>` from `raster_space`, `depth_space`, `depth_from_registers`, and `blend_from_registers` so `Named::find` and `name_from_registers` stop immediately once every wanted hash (or the current record's target hash) has been matched. - Updated existing unit tests and added `raster_space_short_circuits_on_break` to verify early termination. ### Scope Trimmed to only the `ControlFlow` early exits per triage feedback; candidate generation in `blend_from_registers` and `raster_space` is unchanged. ### Verification - `cargo test -p victory-game --locked` - `cargo clippy -p victory-game --all-targets --target x86_64-pc-windows-msvc --locked -- -D warnings` - `cargo test -p xtask --locked`
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:09:36 +00:00
github-bot force-pushed github-bot/gh-2575 from d8831f29a4 to dfcfa60fb7 2026-11-26 06:31:19 +00:00 Compare
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 22:16 UTC · original · edited 2026-11-26 07:18 UTC

Automated triage for the maintainers.

Needs work. Re-reviewed at dfcfa60. The visited < 2_000_000 assertion is gone, and the rewrite of crates/victory-game/src/pipelines.rs still reads as behaviour-preserving (ControlFlow early exits, the array forms of per_target/twins, the reused targets buffers, bases dedup).

Reply to the author: you are right, and our earlier comment was wrong: apps/victory/src/prebuild.rs calls Named::find during victory prebuild. That is still a one-off offline step, though. Your benchmark uses a pack whose wanted states are all D3D12 defaults. That is the best case for the early exits, because enumeration stops at once. With a real pack, any hash that is never named still walks the whole space. What would change the verdict: the time of Named::find in a real victory prebuild run, before and after, as a share of the whole command. Timings only, no title data. If that gain is small, a smaller change limited to the early exits would be easier to take.

CI: check passing.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 22:16 UTC · [original](https://github.com/Marvisak/VIctory/pull/2575#issuecomment-7176159187) · edited 2026-11-26 07:18 UTC <!-- victory-triage v1 head=dfcfa60fb785a5ba6a271d511ca444a25c83fdec verdict=needs-work at=2026-11-26T07:18:12Z --> Automated triage for the maintainers. **Needs work.** Re-reviewed at `dfcfa60`. The `visited < 2_000_000` assertion is gone, and the rewrite of `crates/victory-game/src/pipelines.rs` still reads as behaviour-preserving (`ControlFlow` early exits, the array forms of `per_target`/`twins`, the reused `targets` buffers, `bases` dedup). **Reply to the author:** you are right, and our earlier comment was wrong: `apps/victory/src/prebuild.rs` calls `Named::find` during `victory prebuild`. That is still a one-off offline step, though. Your benchmark uses a pack whose wanted states are all D3D12 defaults. That is the best case for the early exits, because enumeration stops at once. With a real pack, any hash that is never named still walks the whole space. What would change the verdict: the time of `Named::find` in a real `victory prebuild` run, before and after, as a share of the whole command. Timings only, no title data. If that gain is small, a smaller change limited to the early exits would be easier to take. CI: `check` passing. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠reeledMarek on GitHub · 2026-11-26 05:56 UTC · original

Updated to address the triage feedback:

  • Removed the iteration-order visited < 2_000_000 assertion from the_depth_space_holds_the_d3d12_default.
  • Note: Named::find is called by apps/victory/src/prebuild.rs:92 during victory prebuild.
  • Release-mode benchmark (cargo test --release -p victory-game, 9 runs, synthetic pack with matched D3D12 default depth-stencil and default rasterizer states, main 63bcca4 vs this PR):
    • main: median 153.94 ms (min 153.66 ms, max 157.13 ms)
    • this PR: median 12.22 ms (min 12.21 ms, max 12.32 ms) — 12.6× faster (-92.1%).
**@⁠reeledMarek** on GitHub · 2026-11-26 05:56 UTC · [original](https://github.com/Marvisak/VIctory/pull/2575#issuecomment-7183937594) Updated to address the triage feedback: - Removed the iteration-order `visited < 2_000_000` assertion from `the_depth_space_holds_the_d3d12_default`. - Note: `Named::find` is called by `apps/victory/src/prebuild.rs:92` during `victory prebuild`. - Release-mode benchmark (`cargo test --release -p victory-game`, 9 runs, synthetic pack with matched D3D12 default depth-stencil and default rasterizer states, `main` `63bcca4` vs this PR): - `main`: median **153.94 ms** (min 153.66 ms, max 157.13 ms) - this PR: median **12.22 ms** (min 12.21 ms, max 12.32 ms) — **12.6× faster (-92.1%)**.
github-bot changed title from Game: skip redundant pipeline state enumeration and eliminate inner-loop blend Vec allocations to Game: short-circuit pipeline state enumeration once wanted hashes are found 2026-11-26 11:10:53 +00:00
github-bot force-pushed github-bot/gh-2575 from dfcfa60fb7 to a894f0d59b 2026-11-26 11:10:53 +00:00 Compare
Author
Owner

@⁠reeledMarek on GitHub · 2026-11-26 10:39 UTC · original

Trimmed this PR down to only the ControlFlow early exits (and rebased onto current main), dropping the blend_from_registers allocation rewrite so the change stays small and focused as suggested.

**@⁠reeledMarek** on GitHub · 2026-11-26 10:39 UTC · [original](https://github.com/Marvisak/VIctory/pull/2575#issuecomment-7189659581) Trimmed this PR down to only the `ControlFlow` early exits (and rebased onto current `main`), dropping the `blend_from_registers` allocation rewrite so the change stays small and focused as suggested.
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2575/head:github-bot/gh-2575'
git switch 'github-bot/gh-2575'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2575'
git switch 'github-bot/gh-2575'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2575'
git switch 'github-bot/gh-2575'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2575'
git switch 'main'
git merge --squash 'github-bot/gh-2575'
git switch 'main'
git merge --ff-only 'github-bot/gh-2575'
git switch 'main'
git merge 'github-bot/gh-2575'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!2575
No description provided.