victory: translate --cache and the pre-build say where their time went (slowest shaders and pipelines, library saves) #2949

Open
0xkn0wh3r3 wants to merge 2 commits from upstream-pr/2951 into main
0xkn0wh3r3 commented 2026-11-26 01:22:46 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by 0xkn0wh3r3 on 2026-11-26T01:22:46Z.


A warm-up of a title's shaders (translate --cache --pipelines) can take many minutes. Its output says how many shaders were translated and how many pipelines were made, but not whether the time went to our translator or the driver, nor which shaders.

What

At their end, both halves now print a time section:

  • translate --cache: the time spent translating containers, summed over the worker threads, and the 10 slowest by hash. Only containers translated now are counted, not cache hits.
  • The pipeline pre-build:
    • time translating each pipeline's shaders, or finding them in the cache;
    • time making host pipelines (the driver's compilation, or the library's lookup);
    • for each, the 10 slowest pipelines by key and shaders;
    • library saves: how many, how long, and how long the library was locked while being serialised. Pipelines being made wait to be stored meanwhile. The library is about 1.7 GB on NVIDIA and is saved every 20 s during a pre-build.

Prebuild::make_timed returns the two times, and victory_gpu::pipeline::library_saves reports the saves. What gets made doesn't change.

Why: it's the measurement to take before choosing between the open speed-ups for long warm-ups. Candidates are the translator's slow passes (#2662, #2640, #2657, #2665), smaller emitted programs (#2150, #2825), sharded library saves (#1653), and worker counts (#2752).

Tests

  • slowest::tests::it_sums_all_and_names_the_slowest: the totals are summed, the 10 slowest are kept in order, and only items that make the top 10 are named.
  • cargo test -p victory and -p victory-gpu --lib pipeline pass.
  • cargo clippy --locked -p victory -p victory-gpu --all-targets is clean, with and without --features diagnostics.

Not run on a title here: there are no game files on this machine. The report is meant to be read from a real warm-up's output.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6617346514 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2951). Originally posted by [0xkn0wh3r3](https://github.com/0xkn0wh3r3) on 2026-11-26T01:22:46Z. --- A warm-up of a title's shaders (`translate --cache --pipelines`) can take many minutes. Its output says how many shaders were translated and how many pipelines were made, but not whether the time went to our translator or the driver, nor which shaders. ## What At their end, both halves now print a `time` section: - **`translate --cache`:** the time spent translating containers, summed over the worker threads, and the 10 slowest by hash. Only containers translated now are counted, not cache hits. - **The pipeline pre-build:** - time translating each pipeline's shaders, or finding them in the cache; - time making host pipelines (the driver's compilation, or the library's lookup); - for each, the 10 slowest pipelines by key and shaders; - library saves: how many, how long, and how long the library was locked while being serialised. Pipelines being made wait to be stored meanwhile. The library is about 1.7 GB on NVIDIA and is saved every 20 s during a pre-build. `Prebuild::make_timed` returns the two times, and `victory_gpu::pipeline::library_saves` reports the saves. What gets made doesn't change. Why: it's the measurement to take before choosing between the open speed-ups for long warm-ups. Candidates are the translator's slow passes (#2662, #2640, #2657, #2665), smaller emitted programs (#2150, #2825), sharded library saves (#1653), and worker counts (#2752). ## Tests - `slowest::tests::it_sums_all_and_names_the_slowest`: the totals are summed, the 10 slowest are kept in order, and only items that make the top 10 are named. - `cargo test -p victory` and `-p victory-gpu --lib pipeline` pass. - `cargo clippy --locked -p victory -p victory-gpu --all-targets` is clean, with and without `--features diagnostics`. Not run on a title here: there are no game files on this machine. The report is meant to be read from a real warm-up's output.
cloph-dsp commented 2026-11-26 02:07:10 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by cloph-dsp on 2026-11-26T01:35:05Z.


Local verification on Windows / rustc 1.100.0 / MSVC, no game data, no GPU, no clippy/rustup.

  • Diff against merge-base 842b0cb: 7 files, +187/-6. git diff --check flags the same trailing whitespace in README.md:17 (displayed. ).
  • Negative control: it_sums_all_and_names_the_slowest is absent from the base commit.
  • cargo test --locked -p victory --bin victory -- slowest::tests::it_sums_all_and_names_the_slowest --exact --quiet -> 1 passed, 14 filtered (CARGO_BUILD_JOBS=2).
  • Full binary tests: cargo test --locked -p victory --bin victory --quiet -> 15 passed, 0 failed.
  • Only a minor pre-existing warning in victory-hle.

AI-assisted (Hy4 flash).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7179918889 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2951#issuecomment-7179918889). Originally posted by [cloph-dsp](https://github.com/cloph-dsp) on 2026-11-26T01:35:05Z. --- Local verification on Windows / rustc 1.100.0 / MSVC, no game data, no GPU, no clippy/rustup. - Diff against merge-base 842b0cb: 7 files, +187/-6. `git diff --check` flags the same trailing whitespace in README.md:17 (`displayed. `). - Negative control: `it_sums_all_and_names_the_slowest` is absent from the base commit. - `cargo test --locked -p victory --bin victory -- slowest::tests::it_sums_all_and_names_the_slowest --exact --quiet` -> 1 passed, 14 filtered (CARGO_BUILD_JOBS=2). - Full binary tests: `cargo test --locked -p victory --bin victory --quiet` -> 15 passed, 0 failed. - Only a minor pre-existing warning in victory-hle. AI-assisted (Hy4 flash).
fuzeofficlal commented 2026-11-26 02:07:11 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T01:35:14Z.


Code review and Windows 11 verification at head 19a68c592fe7 on main (63bcca43c6a0):

  • Code review (apps/victory/src/slowest.rs, crates/victory-gpu/src/pipeline/library.rs):
    • Slowest accumulates total_us and count lock-free via AtomicU64, locking kept: Mutex<Vec<(Duration, String)>> only for Top-10 entries and evaluating name: impl FnOnce() -> String lazily only when a duration enters the top 10 (zero string allocations on the fast path).
    • library::SAVES records save count, total time, and lock-hold time cleanly (skipping lock/counters when added == 0 && !prebuilt_changed && !USED_CHANGED; minor non-blocking note: if zeroed/Serialize returns Err inside the lock, the Timed drop guard still bumps SAVES[2] without bumping SAVES[0]/SAVES[1]). Prebuild::make_timed splits monotonic Instant translate vs create durations cleanly.
  • Verified (Windows 11, Rust 1.98.1):
    • cargo xtask policy: 192 files ok; cargo clippy -p victory -p victory-gpu --all-targets -- -D warnings: 0 warnings
    • cargo test --locked -p victory: 19/19 passed (15 unit including it_sums_all_and_names_the_slowest + 4 integration)
    • victory-gpu --lib -- pipeline:: (RTX 5090, VICTORY_D3D12_DEBUG=1): 23/23 passed.

LGTM.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7179921248 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2951#issuecomment-7179921248). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T01:35:14Z. --- Code review and Windows 11 verification at head `19a68c592fe7` on `main` (`63bcca43c6a0`): - **Code review (`apps/victory/src/slowest.rs`, `crates/victory-gpu/src/pipeline/library.rs`)**: - `Slowest` accumulates `total_us` and `count` lock-free via `AtomicU64`, locking `kept: Mutex<Vec<(Duration, String)>>` only for Top-10 entries and evaluating `name: impl FnOnce() -> String` lazily only when a duration enters the top 10 (zero string allocations on the fast path). - `library::SAVES` records save count, total time, and lock-hold time cleanly (skipping lock/counters when `added == 0 && !prebuilt_changed && !USED_CHANGED`; minor non-blocking note: if `zeroed`/`Serialize` returns `Err` inside the lock, the `Timed` drop guard still bumps `SAVES[2]` without bumping `SAVES[0]`/`SAVES[1]`). `Prebuild::make_timed` splits monotonic `Instant` translate vs create durations cleanly. - **Verified (Windows 11, Rust 1.98.1)**: - `cargo xtask policy`: `192 files ok`; `cargo clippy -p victory -p victory-gpu --all-targets -- -D warnings`: 0 warnings - `cargo test --locked -p victory`: **19/19 passed** (15 unit including `it_sums_all_and_names_the_slowest` + 4 integration) - `victory-gpu --lib -- pipeline::` (RTX 5090, `VICTORY_D3D12_DEBUG=1`): **23/23 passed**. LGTM.
kotekompotek commented 2026-11-26 03:04:38 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-26T02:28:44Z.

Review: COMMENTED


Verified: Slowest sums all durations but only formats names for entries that make the top-10 (locked vec, lazy FnOnce name). The pre-build timing split is clean — translated = first quiet dispatch, created = elapsed minus translated. SAVES[2] correctly measures only the locked serialize window via the Timed drop guard while SAVES[1] is the whole save including atomic write. translate --cache gates on translated+refused>0 and marks refused entries.

<!-- greyfinch-sync:Marvisak/VIctory:review:6067759841 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2951#pullrequestreview-6067759841). Originally posted by [kotekompotek](https://github.com/kotekompotek) on 2026-11-26T02:28:44Z. **Review:** COMMENTED --- Verified: Slowest sums all durations but only formats names for entries that make the top-10 (locked vec, lazy FnOnce name). The pre-build timing split is clean — translated = first quiet dispatch, created = elapsed minus translated. SAVES[2] correctly measures only the locked serialize window via the Timed drop guard while SAVES[1] is the whole save including atomic write. translate --cache gates on translated+refused>0 and marks refused entries.
Marvisak commented 2026-11-26 06:03:41 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-26T05:24:58Z.


Automated triage for the maintainers.

Merge candidate (recommending a look, not approving). Thanks for taking the minor point. In 2a7976c2, library::save (crates/victory-gpu/src/pipeline/library.rs) adds the time it held the lock to SAVES[2] only on the Serialize success path, and the Timed guard is gone. Early returns (failed zeroed or Serialize) no longer add lock time without a counted save. The rest is as reviewed before: apps/victory/src/slowest.rs keeps totals and the 10 slowest by name, Prebuild::make_timed splits translate time from create time, and nothing about what gets built changes.

CI: passing (check).


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7183465175 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2951#issuecomment-7183465175). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-26T05:24:58Z. --- <!-- victory-triage v1 head=2a7976c2d29e57e0096f3bdd0fa9612190d685af verdict=merge-candidate at=2026-11-26T07:19:03Z --> Automated triage for the maintainers. **Merge candidate** (recommending a look, not approving). Thanks for taking the minor point. In 2a7976c2, `library::save` (`crates/victory-gpu/src/pipeline/library.rs`) adds the time it held the lock to `SAVES[2]` only on the `Serialize` success path, and the `Timed` guard is gone. Early returns (failed `zeroed` or `Serialize`) no longer add lock time without a counted save. The rest is as reviewed before: `apps/victory/src/slowest.rs` keeps totals and the 10 slowest by name, `Prebuild::make_timed` splits translate time from create time, and nothing about what gets built changes. CI: passing (`check`). --- _Generated by [Claude Code](https://claude.ai/code)_
0xkn0wh3r3 commented 2026-11-26 06:03:42 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by 0xkn0wh3r3 on 2026-11-26T05:28:52Z.


Took the minor point in 2a7976c2: library::save now adds the time it held the lock only for saves that serialise, so an early return (failed zeroed or Serialize) no longer adds to SAVES[2] without a counted save. The Timed guard is gone.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7183523038 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2951#issuecomment-7183523038). Originally posted by [0xkn0wh3r3](https://github.com/0xkn0wh3r3) on 2026-11-26T05:28:52Z. --- Took the minor point in 2a7976c2: `library::save` now adds the time it held the lock only for saves that serialise, so an early return (failed `zeroed` or `Serialize`) no longer adds to `SAVES[2]` without a counted save. The `Timed` guard is gone.
Dukestar69 commented 2026-11-26 10:04:36 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T09:11:25Z.

Review: APPROVED


Verified against origin/main (63bcca4):

  • cargo test -p victory -- --test-threads=1: 15 lib + 4 integration tests passed (including slowest::tests::it_sums_all_and_names_the_slowest).
  • cargo clippy -p victory --all-targets -- -D warnings: clean.
  • cargo xtask policy: 192 files ok.

Cleanly reports timing totals and the slowest shaders/pipelines during translate --cache and pre-build.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6071279364 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2951#pullrequestreview-6071279364). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-26T09:11:25Z. **Review:** APPROVED --- Verified against `origin/main` (`63bcca4`): - `cargo test -p victory -- --test-threads=1`: 15 lib + 4 integration tests passed (including `slowest::tests::it_sums_all_and_names_the_slowest`). - `cargo clippy -p victory --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 192 files ok. Cleanly reports timing totals and the slowest shaders/pipelines during `translate --cache` and pre-build. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
fuzeofficlal commented 2026-11-26 15:01:47 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T14:15:30Z.

Review: APPROVED


Reviewed and verified head 2a7976c2d29e57e0096f3bdd0fa9612190d685af (clean merge with origin/main 63bcca43) on Windows 11 x64 with NVIDIA GeForce RTX 5090 and D3D12 WARP (VICTORY_D3D12_DEBUG=1, Rust 1.98.1).

Code review

  • apps/victory/src/slowest.rs (L11-64): accumulates total_us and count via lock-free AtomicU64 (saturating as_micros() cleanly to u64::MAX), guards division by zero with count.max(1) so empty reports produce 0 in 0.0 s with no NaN, bounds retained memory to KEPT = 10 entries, and evaluates name lazily only when an entry enters the top 10.
  • crates/victory-gpu/src/pipeline.rs: Prebuild::make_timed (L668, inside #[cfg(windows)] impl Prebuild) and library_saves (L708, #[cfg(windows)]) preserve non-Windows #[cfg] hygiene and leave pipeline compilation/caching behavior and on-disk library format untouched.
  • crates/victory-gpu/src/pipeline/library.rs (L55, L343, L360-361): SAVES[2] now records lock-held serialization time only on the Serialize success path (avoiding inflated lock time on early error returns), and merges cleanly with #2646 with zero conflicts.
  • apps/victory/src/translate.rs (L340, L377, L435) and prebuild.rs (L227, L248, L287): cleanly exclude cache hits from translation timings and skip the time section when no work ran.

Verification

  • cargo xtask policy: 192 files ok
  • cargo clippy --workspace --all-targets --locked -- -D warnings (default & --all-features): 0 warnings
  • cargo test --locked -p victory -- --test-threads=1: 19/19 passed (15 unit including slowest::tests::it_sums_all_and_names_the_slowest + 4 integration)
  • cargo test --locked -p victory-gpu --lib -- pipeline::: 23/23 passed (RTX 5090 default), 26/26 passed (RTX 5090 --features diagnostics + VICTORY_D3D12_DEBUG=1), 26/26 passed (WARP --features diagnostics + VICTORY_D3D12_DEBUG=1)
  • Additional local probe verified empty Slowest (no NaN), all-zero durations, Duration::MAX clamping, and 8-thread concurrent Slowest::add (8,000 items: exact total, exact count, top-10 sorted descending); combined #2951 + #2646 merge passed --all-features Clippy cleanly.

Clean, useful diagnostics; approving.

<!-- greyfinch-sync:Marvisak/VIctory:review:6075628089 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2951#pullrequestreview-6075628089). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T14:15:30Z. **Review:** APPROVED --- Reviewed and verified head `2a7976c2d29e57e0096f3bdd0fa9612190d685af` (clean merge with `origin/main` `63bcca43`) on Windows 11 x64 with **NVIDIA GeForce RTX 5090** and **D3D12 WARP** (`VICTORY_D3D12_DEBUG=1`, Rust 1.98.1). **Code review** - `apps/victory/src/slowest.rs` (`L11-64`): accumulates `total_us` and `count` via lock-free `AtomicU64` (saturating `as_micros()` cleanly to `u64::MAX`), guards division by zero with `count.max(1)` so empty reports produce `0 in 0.0 s` with no `NaN`, bounds retained memory to `KEPT = 10` entries, and evaluates `name` lazily only when an entry enters the top 10. - `crates/victory-gpu/src/pipeline.rs`: `Prebuild::make_timed` (`L668`, inside `#[cfg(windows)] impl Prebuild`) and `library_saves` (`L708`, `#[cfg(windows)]`) preserve non-Windows `#[cfg]` hygiene and leave pipeline compilation/caching behavior and on-disk library format untouched. - `crates/victory-gpu/src/pipeline/library.rs` (`L55`, `L343`, `L360-361`): `SAVES[2]` now records lock-held serialization time only on the `Serialize` success path (avoiding inflated lock time on early error returns), and merges cleanly with #2646 with zero conflicts. - `apps/victory/src/translate.rs` (`L340`, `L377`, `L435`) and `prebuild.rs` (`L227`, `L248`, `L287`): cleanly exclude cache hits from translation timings and skip the `time` section when no work ran. **Verification** - `cargo xtask policy`: `192 files ok` - `cargo clippy --workspace --all-targets --locked -- -D warnings` (default & `--all-features`): 0 warnings - `cargo test --locked -p victory -- --test-threads=1`: **19/19 passed** (15 unit including `slowest::tests::it_sums_all_and_names_the_slowest` + 4 integration) - `cargo test --locked -p victory-gpu --lib -- pipeline::`: **23/23 passed** (RTX 5090 default), **26/26 passed** (RTX 5090 `--features diagnostics` + `VICTORY_D3D12_DEBUG=1`), **26/26 passed** (WARP `--features diagnostics` + `VICTORY_D3D12_DEBUG=1`) - Additional local probe verified empty `Slowest` (no `NaN`), all-zero durations, `Duration::MAX` clamping, and 8-thread concurrent `Slowest::add` (8,000 items: exact total, exact count, top-10 sorted descending); combined `#2951 + #2646` merge passed `--all-features` Clippy cleanly. Clean, useful diagnostics; approving.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/2951:upstream-pr/2951'
git switch 'upstream-pr/2951'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/2951'
git switch 'upstream-pr/2951'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2951'
git switch 'upstream-pr/2951'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2951'
git switch 'main'
git merge --squash 'upstream-pr/2951'
git switch 'main'
git merge --ff-only 'upstream-pr/2951'
git switch 'main'
git merge 'upstream-pr/2951'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
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.

Reference
Marvisak/VIctory!2949
No description provided.