Run: the title's warm-up starts itself, at load #2809

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

@⁠kais7654 on GitHub · 2026-11-25 21:07 UTC · original
kais7654:warm/the-runs-own-prebuild → main · +107 −1 · 5 files · 2 commits · open

What

victory run now starts the warm-up of victory translate --cache --pipelines itself: after the title's imports are bound and before its main thread spawns, a victory-prebuild thread (below the title's priority, up to 4 threads) walks the title's folder and fills the two caches a run reads — the translated-shader cache (<cache>/shaders) and the host pipeline library (<cache>/pipelines). It saves what it makes as it grows: a stopped run keeps its work and the next one skips its entries. VICTORY_PREBUILD=0 leaves the warm-up to the command, and the command keeps its progress lines; the run's warm-up stays quiet (its console is the title's).

Why

The offline pre-build already makes every pipeline of the shader pack ahead of a run — but it was a command the README suggested before the first play. Who skipped it paid in the first runs: Grand Theft Auto VI's first world frame wants over 1,200 new pipelines (decision 0007: that frame took more than 30 s on the recording threads), and the shaders translate at first use, their draws waiting. With the warm-up started at load, the first run digs the caches while the title is still on its menus (below its priority, so it does not take the CPU from loading), and the next one finds everything there: what the frame asks for is loaded from the library, not compiled.

Notes

  • The warm-up path is the run's own code (victory_gpu::pipeline::Prebuild → the pipeline library), exactly translate --cache --pipelines with use_progress(false); the host device is the run's static host.
  • On the run side the warm-up covers the title's folder; translate --cache --pipelines stays the way to warm other folders and to watch progress.
  • A test covers the gate (VICTORY_PREBUILD refuses 0 and off); README documents the behavior.

AI-assisted: implemented with Mistral Vibe.

**@⁠kais7654** on GitHub · 2026-11-25 21:07 UTC · [original](https://github.com/Marvisak/VIctory/pull/2809) `kais7654:warm/the-runs-own-prebuild` → `main` · +107 −1 · 5 files · 2 commits · open ## What `victory run` now starts the warm-up of `victory translate --cache --pipelines` itself: after the title's imports are bound and before its main thread spawns, a `victory-prebuild` thread (below the title's priority, up to 4 threads) walks the title's folder and fills the two caches a run reads — the translated-shader cache (`<cache>/shaders`) and the host pipeline library (`<cache>/pipelines`). It saves what it makes as it grows: a stopped run keeps its work and the next one skips its entries. `VICTORY_PREBUILD=0` leaves the warm-up to the command, and the command keeps its progress lines; the run's warm-up stays quiet (its console is the title's). ## Why The offline pre-build already makes every pipeline of the shader pack ahead of a run — but it was a command the README suggested before the first play. Who skipped it paid in the first runs: Grand Theft Auto VI's first world frame wants over 1,200 new pipelines (decision 0007: that frame took more than 30 s on the recording threads), and the shaders translate at first use, their draws waiting. With the warm-up started at load, the first run digs the caches while the title is still on its menus (below its priority, so it does not take the CPU from loading), and the next one finds everything there: what the frame asks for is loaded from the library, not compiled. ## Notes - The warm-up path is the run's own code (`victory_gpu::pipeline::Prebuild` → the pipeline library), exactly `translate --cache --pipelines` with `use_progress(false)`; the host device is the run's static host. - On the run side the warm-up covers the title's folder; `translate --cache --pipelines` stays the way to warm other folders and to watch progress. - A test covers the gate (`VICTORY_PREBUILD` refuses `0` and `off`); README documents the behavior. AI-assisted: implemented with Mistral Vibe.
The warm-up of `translate --cache --pipelines` (every shader container
into the disk cache, every pipeline of the shader pack into the host
pipeline library) was a command the run's instructions suggested before
the first play -- who did not run it spent the first runs making
pipelines as they drew (Grand Theft Auto VI's first world frame wants
over 1,200) and translating at first use.

A run starts it itself: the title's folder, on up to four threads below
the title's own, after its imports are bound and before its main thread
spawns; what it makes is saved as it grows, so the next run finds it and
this one stopped keeps its work. Its progress lines stay with the
command (the run's console is the title's), and `VICTORY_PREBUILD=0`
leaves the warm-up to the command again -- pointed at other folders,
showing progress.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <[email protected]>
A thread of the run's own does not hand its priority on (Windows makes a
child one normal again): only the warm-up thread was below normal, the
workers it makes -- which do the translating -- competed with the title's
own. They start below its priority now: the run arms them as the
warm-up's (the command's workers keep their caller's priority).

Reviewed on #2809 by kotekompotek.

Generated by Mistral Vibe.

Co-Authored-By: Mistral Vibe <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:14:46 +00:00
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-25 21:23 UTC · original

Reviewed and tested ec64ba5b on Windows 11 (rustc 1.98.1 MSVC) against main (13f91ca).

Code review

Cache integrity looks safe on early exit (Cache::get_or_convert and library::write_atomically stage to .tmp-{pid}-{n} and rename atomically under WRITING, and use_shader_cache/use_pipeline_cache are already initialized before start_warm_up). However, four practical issues stand out for running warm-up concurrently with title launch:

  1. Windows worker threads do not inherit THREAD_PRIORITY_BELOW_NORMAL (run.rs:72-76): SetThreadPriority is called only on the coordinator thread, with the comment // The scoped workers spawn from here (below the title's threads). On Windows, CreateThread (used by std::thread::scope) always starts new threads at THREAD_PRIORITY_NORMAL regardless of the creator's priority, so up to 4 scoped workers in translate::warm and prebuild::run still compete at normal priority with the title's own threads. Each worker needs SetThreadPriority inside its own thread body (as in pipeline/make.rs:284).
  2. Startup peak RAM spike: translate::warm and prebuild::run read files up to MAX_FILE = 2 GiB whole via std::fs::read, and prebuild::run retains files: Vec<(PathBuf, Vec<u8>)> across the run—right while the title is mapping its executable and allocating startup memory.
  3. Not actually quiet on stdout/stderr: use_progress(false) only suppresses translate::report(); translate::warm (translate.rs:429-434) and prebuild::run (prebuild.rs:59, 112, 324, 331) still print cache/containers/pipelines lines to the title's console.
  4. Shared global stats & library.lock() contention: warm-up shares shader_cache::{HITS, MISSES} / library::{MADE, LOADED} with live title execution (skewing frame/run logs), initializes host() early, and Prebuild::make() calls library::save(false) every 20 s holding library.lock() during Serialize, which can briefly stall live pipeline lookups.

Verification

  • cargo test --locked -p victory: 13/13 passed; cargo clippy --locked -p victory --all-targets -- -D warnings (default & --features diagnostics): 0 warnings; cargo xtask policy: 184 files ok.
**@⁠fuzeofficlal** on GitHub · 2026-11-25 21:23 UTC · [original](https://github.com/Marvisak/VIctory/pull/2809#issuecomment-7175014443) Reviewed and tested `ec64ba5b` on Windows 11 (`rustc 1.98.1` MSVC) against `main` (`13f91ca`). ### Code review Cache integrity looks safe on early exit (`Cache::get_or_convert` and `library::write_atomically` stage to `.tmp-{pid}-{n}` and rename atomically under `WRITING`, and `use_shader_cache`/`use_pipeline_cache` are already initialized before `start_warm_up`). However, four practical issues stand out for running warm-up concurrently with title launch: 1. **Windows worker threads do not inherit `THREAD_PRIORITY_BELOW_NORMAL` (`run.rs:72-76`)**: `SetThreadPriority` is called only on the coordinator thread, with the comment `// The scoped workers spawn from here (below the title's threads).` On Windows, `CreateThread` (used by `std::thread::scope`) always starts new threads at `THREAD_PRIORITY_NORMAL` regardless of the creator's priority, so up to 4 scoped workers in `translate::warm` and `prebuild::run` still compete at normal priority with the title's own threads. Each worker needs `SetThreadPriority` inside its own thread body (as in `pipeline/make.rs:284`). 2. **Startup peak RAM spike**: `translate::warm` and `prebuild::run` read files up to `MAX_FILE = 2 GiB` whole via `std::fs::read`, and `prebuild::run` retains `files: Vec<(PathBuf, Vec<u8>)>` across the run—right while the title is mapping its executable and allocating startup memory. 3. **Not actually quiet on stdout/stderr**: `use_progress(false)` only suppresses `translate::report()`; `translate::warm` (`translate.rs:429-434`) and `prebuild::run` (`prebuild.rs:59, 112, 324, 331`) still print `cache`/`containers`/`pipelines` lines to the title's console. 4. **Shared global stats & `library.lock()` contention**: warm-up shares `shader_cache::{HITS, MISSES}` / `library::{MADE, LOADED}` with live title execution (skewing frame/run logs), initializes `host()` early, and `Prebuild::make()` calls `library::save(false)` every 20 s holding `library.lock()` during `Serialize`, which can briefly stall live pipeline lookups. ### Verification - `cargo test --locked -p victory`: **13/13 passed**; `cargo clippy --locked -p victory --all-targets -- -D warnings` (default & `--features diagnostics`): **0 warnings**; `cargo xtask policy`: **184 files ok**.
Author
Owner

@⁠cloph-dsp on GitHub · 2026-11-25 21:25 UTC · original

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

  • cargo test --locked -p victory --quiet -> 11 + 2 tests passed, 0 failed.
  • Targeted: cargo test --locked -p victory --bin victory the_warm_up_starts_unless_asked_off --quiet -> 1 passed, 10 filtered out.
  • git diff --check origin/main..HEAD clean.
  • Negative control: the_warm_up_starts_unless_asked_off is absent from origin/main, so the gate test is new here.
  • The change starts a low-priority Prebuild warm-up thread at run load unless VICTORY_PREBUILD=0/off, with progress output silenced during a run; the pure gate logic is what the synthetic test covers, no title assets were used.
  • Only pre-existing deprecation warnings in victory-gpu/object.rs and victory-hle/xmem.rs.
  • Noted one COMMENTED review by kotekompotek; no formal approval.

AI-assisted (Hy4 flash).

**@⁠cloph-dsp** on GitHub · 2026-11-25 21:25 UTC · [original](https://github.com/Marvisak/VIctory/pull/2809#issuecomment-7175056634) Local verification on Windows / rustc 1.100.0 / MSVC, no game data, no GPU, no clippy/rustup, CARGO_BUILD_JOBS=2. - `cargo test --locked -p victory --quiet` -> 11 + 2 tests passed, 0 failed. - Targeted: `cargo test --locked -p victory --bin victory the_warm_up_starts_unless_asked_off --quiet` -> 1 passed, 10 filtered out. - `git diff --check origin/main..HEAD` clean. - Negative control: `the_warm_up_starts_unless_asked_off` is absent from origin/main, so the gate test is new here. - The change starts a low-priority `Prebuild` warm-up thread at run load unless `VICTORY_PREBUILD=0/off`, with progress output silenced during a run; the pure gate logic is what the synthetic test covers, no title assets were used. - Only pre-existing deprecation warnings in victory-gpu/object.rs and victory-hle/xmem.rs. - Noted one COMMENTED review by kotekompotek; no formal approval. AI-assisted (Hy4 flash).
Author
Owner

@⁠kais7654 on GitHub · 2026-11-25 22:03 UTC · original

Fix applied: run's warm-up now arms its workers themselves — each worker
warm makes starts with SetThreadPriority(THREAD_PRIORITY_BELOW_NORMAL)
of its own (a run's; translate's workers keep their caller's priority).
The warm-up thread itself stays below normal as before
(fb2d391). Clippy 0 on both feature profiles; the app's tests pass.

**@⁠kais7654** on GitHub · 2026-11-25 22:03 UTC · [original](https://github.com/Marvisak/VIctory/pull/2809#issuecomment-7175885501) Fix applied: `run`'s warm-up now arms its workers themselves — each worker `warm` makes starts with `SetThreadPriority(THREAD_PRIORITY_BELOW_NORMAL)` of its own (a run's; `translate`'s workers keep their caller's priority). The warm-up thread itself stays below normal as before (`fb2d391`). Clippy 0 on both feature profiles; the app's tests pass.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-26 02:19 UTC · original

Automated triage for the maintainers.

This makes victory run start the shader/pipeline warm-up (translate::warm) on a below-normal thread while the title loads, unless VICTORY_PREBUILD=0 is set. It adds windows-sys as a new dependency of apps/victory (Cargo.toml and Cargo.lock), so it needs the maintainer's decision in any case. Points still open from the review above:

  • use_progress(false) only silences translate::report. The warm-up's other output (for example in prebuild::run) still prints to the title's console.
  • translate::warm reads whole files (up to MAX_FILE) while the title is loading, which raises peak memory at startup.
  • Turning a background job on by default for every run changes run behaviour for everyone. A short note on what it costs during loading, measured on a run, would help the decision.

CI: passing.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-26 02:19 UTC · [original](https://github.com/Marvisak/VIctory/pull/2809#issuecomment-7180687751) <!-- victory-triage v1 head=fb2d391bc22a3d6bd8c27a8c67d1371ec48df216 verdict=needs-work at=2026-11-26T02:19:05Z --> Automated triage for the maintainers. This makes `victory run` start the shader/pipeline warm-up (`translate::warm`) on a below-normal thread while the title loads, unless `VICTORY_PREBUILD=0` is set. It adds `windows-sys` as a new dependency of `apps/victory` (Cargo.toml and Cargo.lock), so it **needs the maintainer's decision** in any case. Points still open from the review above: - `use_progress(false)` only silences `translate::report`. The warm-up's other output (for example in `prebuild::run`) still prints to the title's console. - `translate::warm` reads whole files (up to `MAX_FILE`) while the title is loading, which raises peak memory at startup. - Turning a background job on by default for every run changes run behaviour for everyone. A short note on what it costs during loading, measured on a run, would help the decision. CI: passing. --- _Generated by [Claude Code](https://claude.ai/code)_
This pull request can be merged automatically.
This branch is out-of-date with the base branch
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/2809/head:github-bot/gh-2809'
git switch 'github-bot/gh-2809'

Merge

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