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

Open
github-bot wants to merge 2 commits from github-bot/gh-2951 into main AGit
Owner

@⁠0xkn0wh3r3 on GitHub · 2026-11-26 01:22 UTC · original
0xkn0wh3r3:tools/build-timing → main · +175 −3 · 6 files · 2 commits · open

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.

**@⁠0xkn0wh3r3** on GitHub · 2026-11-26 01:22 UTC · [original](https://github.com/Marvisak/VIctory/pull/2951) `0xkn0wh3r3:tools/build-timing` → `main` · +175 −3 · 6 files · 2 commits · open 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.
A warm-up of a title's shaders can take many minutes, and nothing said
whether the time was ours or the driver's, nor which shaders. At their
end both now print a "time" section:

- translate --cache: the time translating containers (summed over the
  worker threads) and the 10 slowest by hash;
- the pre-build: the time translating pipelines' shaders (or finding
  them in the cache), the time making host pipelines (the driver's
  compilation, or the library's lookup), each with the 10 slowest
  pipelines by key and shaders, and the library saves: how many, how
  long, and how long the library was locked serialising (pipelines being
  made wait to be stored meanwhile; the library is about 1.7 GB on
  NVIDIA and saved every 20 s).

Prebuild::make_timed returns the two times; victory_gpu::pipeline::
library_saves the saves. Nothing changes in what is made.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:18:24 +00:00
The time spent with the library's lock held is counted only for saves that serialise it, so SAVES[2] stays part of the time the counted saves took.
Author
Owner

@⁠cloph-dsp on GitHub · 2026-11-26 01:35 UTC · original

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).

**@⁠cloph-dsp** on GitHub · 2026-11-26 01:35 UTC · [original](https://github.com/Marvisak/VIctory/pull/2951#issuecomment-7179918889) 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).
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 01:35 UTC · original

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.

**@⁠fuzeofficlal** on GitHub · 2026-11-26 01:35 UTC · [original](https://github.com/Marvisak/VIctory/pull/2951#issuecomment-7179921248) 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.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-26 05:24 UTC · original · edited 2026-11-26 07:19 UTC

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

**@⁠Marvisak** on GitHub · 2026-11-26 05:24 UTC · [original](https://github.com/Marvisak/VIctory/pull/2951#issuecomment-7183465175) · edited 2026-11-26 07:19 UTC <!-- 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)_
Author
Owner

@⁠0xkn0wh3r3 on GitHub · 2026-11-26 05:28 UTC · original

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.

**@⁠0xkn0wh3r3** on GitHub · 2026-11-26 05:28 UTC · [original](https://github.com/Marvisak/VIctory/pull/2951#issuecomment-7183523038) 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.
Author
Owner

@⁠kotekompotek on GitHub · 2026-11-26 02:28 UTC · original · reviewed

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.

**@⁠kotekompotek** on GitHub · 2026-11-26 02:28 UTC · [original](https://github.com/Marvisak/VIctory/pull/2951#pullrequestreview-6067759841) · **reviewed** 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.
Author
Owner

@⁠Dukestar69 on GitHub · 2026-11-26 09:11 UTC · original · approved these changes

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).

**@⁠Dukestar69** on GitHub · 2026-11-26 09:11 UTC · [original](https://github.com/Marvisak/VIctory/pull/2951#pullrequestreview-6071279364) · **approved these changes** 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).
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 14:15 UTC · original · approved these changes

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.

**@⁠fuzeofficlal** on GitHub · 2026-11-26 14:15 UTC · [original](https://github.com/Marvisak/VIctory/pull/2951#pullrequestreview-6075628089) · **approved these changes** 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 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/2951/head:github-bot/gh-2951'
git switch 'github-bot/gh-2951'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2951'
git switch 'github-bot/gh-2951'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2951'
git switch 'github-bot/gh-2951'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2951'
git switch 'main'
git merge --squash 'github-bot/gh-2951'
git switch 'main'
git merge --ff-only 'github-bot/gh-2951'
git switch 'main'
git merge 'github-bot/gh-2951'
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!2951
No description provided.