Stop the shader warm-up file walk when its time budget expires #356

Open
github-bot wants to merge 2 commits from github-bot/gh-356 into a-publier AGit
Owner

@⁠ANDREANIADS on GitHub · 2026-11-26 21:44 UTC · original
ANDREANIADS:fix-warm-scan-deadline → a-publier · +93 −46 · 1 files · 2 commits · open

Fixes #293.

Previously, once VICTORY_WARM_SECONDS expired, worker threads stopped starting translations but the outer loop kept reading every remaining archive from every root. It also scanned and hashed new data before noticing the limit. A shader-free directory could run to completion without reporting the cutoff.

The deadline now gates the directory walk, file reads, archive scanning and workers' acquisition of new jobs. Reads and translations already in flight can complete. A later unlimited run can reuse completed cache entries. Two regression tests cover a zero budget and expiry between files across multiple roots.

Validation

A deterministic comparison of the original and changed warm-up functions used real directory traversal, file reads, worker threads and hashing with a controlled clock and shader cache. The original passed 1/5 cases, and the change passed all 5. When expiry was forced during the first read, the original read and scanned all three files and started three workers. The fix read that first file, then stopped before scanning it or starting a worker. Another case confirmed the next run reused the result of a translation that finished in flight.

I also compared two full Windows victory.exe builds on the same 64 MiB shader-free fixture (eight 8 MiB files in two roots, one worker). Windows GetProcessIoCounters reported the following reads for victory translate --warm all:

Budget Before After
VICTORY_WARM_SECONDS=0 67,108,864 bytes, 16 reads 0 bytes, 0 reads
Unlimited 67,108,864 bytes, 16 reads 67,108,864 bytes, 16 reads

With a one-second budget, a second synthetic fixture visited the same 8 MiB root up to 512 times (4 GiB of possible reads). The baseline scanned all entries in 5.3 s. The patched command read part of the fixture and reported stopping at 1.0 s. Times are from this PC.

All four zero-budget and unlimited commands exited successfully. Only the patched zero-budget run reported stopping at the time limit. The complete CLI binary test suite passed: 24 passed, 0 failed, 0 ignored, including both new tests. For local validation I used Rust 1.98.0 MSVC and an offline dependency lock, with matching dependency versions in the before/after binaries. The repository pins Rust 1.98.1. No game assets were used.

Implemented and tested with Codex.

**@⁠ANDREANIADS** on GitHub · 2026-11-26 21:44 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/356) `ANDREANIADS:fix-warm-scan-deadline` → `a-publier` · +93 −46 · 1 files · 2 commits · open Fixes #293. Previously, once `VICTORY_WARM_SECONDS` expired, worker threads stopped starting translations but the outer loop kept reading every remaining archive from every root. It also scanned and hashed new data before noticing the limit. A shader-free directory could run to completion without reporting the cutoff. The deadline now gates the directory walk, file reads, archive scanning and workers' acquisition of new jobs. Reads and translations already in flight can complete. A later unlimited run can reuse completed cache entries. Two regression tests cover a zero budget and expiry between files across multiple roots. ### Validation A deterministic comparison of the original and changed warm-up functions used real directory traversal, file reads, worker threads and hashing with a controlled clock and shader cache. The original passed 1/5 cases, and the change passed all 5. When expiry was forced during the first read, the original read and scanned all three files and started three workers. The fix read that first file, then stopped before scanning it or starting a worker. Another case confirmed the next run reused the result of a translation that finished in flight. I also compared two full Windows `victory.exe` builds on the same 64 MiB shader-free fixture (eight 8 MiB files in two roots, one worker). Windows `GetProcessIoCounters` reported the following reads for `victory translate --warm all`: | Budget | Before | After | |---|---:|---:| | `VICTORY_WARM_SECONDS=0` | 67,108,864 bytes, 16 reads | **0 bytes, 0 reads** | | Unlimited | 67,108,864 bytes, 16 reads | 67,108,864 bytes, 16 reads | With a **one-second** budget, a second synthetic fixture visited the same 8 MiB root up to 512 times (4 GiB of possible reads). The baseline scanned all entries in 5.3 s. The patched command read part of the fixture and reported stopping at 1.0 s. Times are from this PC. All four zero-budget and unlimited commands exited successfully. Only the patched zero-budget run reported stopping at the time limit. The complete CLI binary test suite passed: 24 passed, 0 failed, 0 ignored, including both new tests. For local validation I used Rust 1.98.0 MSVC and an offline dependency lock, with matching dependency versions in the before/after binaries. The repository pins Rust 1.98.1. No game assets were used. Implemented and tested with Codex.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 00:58:25 +00:00
Author
Owner

@⁠lvndrpup on GitHub · 2026-11-27 04:58 UTC · original · reviewed

This no longer merges into a-publier: #332 (merged as 038c507, "--warm uses every logical core by default") added jobs_is_at_least_one_worker_and_every_core_by_default at the same spot in translate.rs's tests where this PR adds its two. That is the only conflict, and keeping all three tests resolves it.

I merged d18892a into 4eb6cfd that way and checked it on Windows 11 build 26300, Rust 1.98.1, debug:

  • cargo test -p victory: 34 passed, among them warm_zero_budget_stops_without_scanning, warm_expiry_during_a_file_stops_this_root_and_later_roots and #332's test.
  • cargo clippy -p victory --all-targets -- -D warnings: clean.

The bug is still on a-publier: VICTORY_WARM_SECONDS there only stops new shaders from being taken (translate.rs:183), and the walk itself has no deadline. A rebase onto a-publier with the three tests kept should be all this needs.

**@⁠lvndrpup** on GitHub · 2026-11-27 04:58 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/356#pullrequestreview-6083672258) · **reviewed** This no longer merges into `a-publier`: #332 (merged as `038c507`, "--warm uses every logical core by default") added `jobs_is_at_least_one_worker_and_every_core_by_default` at the same spot in `translate.rs`'s tests where this PR adds its two. That is the only conflict, and keeping all three tests resolves it. I merged `d18892a` into `4eb6cfd` that way and checked it on Windows 11 build 26300, Rust 1.98.1, debug: - `cargo test -p victory`: 34 passed, among them `warm_zero_budget_stops_without_scanning`, `warm_expiry_during_a_file_stops_this_root_and_later_roots` and #332's test. - `cargo clippy -p victory --all-targets -- -D warnings`: clean. The bug is still on `a-publier`: `VICTORY_WARM_SECONDS` there only stops new shaders from being taken (`translate.rs:183`), and the walk itself has no deadline. A rebase onto `a-publier` with the three tests kept should be all this needs.
Author
Owner

@⁠adrianmjim on GitHub · 2026-11-27 06:26 UTC · original

Tested on RX 7900 XT (RDNA3), driver 32.0.32029.2010, Windows 11 26300, Rust 1.98.1, release builds. Base a-publier 4eb6cfd vs 4eb6cfd + this PR (d18892a), merged locally. Real game install: 109 files, 93 of them within MAX_FILE (2 GiB), 41.25 GiB in total. --jobs 4, fresh shader cache for each run.

Walk only (translate --warm <list> with a list that matches no hash, so nothing is translated):

  • VICTORY_WARM_SECONDS=0: PR 0.07 s, no game file read. Base 46.4 s, reads all 41.25 GiB.
  • 5 s: PR stops at 5.4-5.9 s after reading 5.1 GiB. Base 42-44 s, reads everything.
  • 30 s: PR 30.2 s, 28.0 GiB. Base 39.9 s, reads everything.
  • Unlimited: both read 41.25 GiB in 189 read ops. Neither prints "stopped at the time limit".
  • With the 5 s and 30 s budgets the PR stops 0.2-0.9 s after the deadline, while the file in flight finishes (files are up to 2 GiB).

With translation (translate --warm all):

  • Unlimited: base 373.8 s, PR 381.8 s, one run each. The gap is smaller than the 36-46 s spread of the walk alone between runs. Same counts on both: 25985 found, 25790 translated, 195 do not translate. The two shader caches are byte-identical (25790 entries).
  • 30 s: PR exits at 30.3 s, base at 47.1 s. Both translated the same 29 shaders. Every entry matches the unlimited cache byte for byte.
  • On this install the walk only reaches the first 1000 shaders after 44-51 s. A 30 s budget is mostly spent reading shader-free files that come first in walk order. This is not caused by this PR.

Other notes:

  • warm() doc says "nothing is made on the GPU". No pipelines are made (the cache only gets shaders/). But precompile opens the host D3D12 device, and probe_view_limit creates descriptor heaps on it. This line is unchanged by the PR.

Not tested: the full test suite on the merge, other GPUs, and budgets other than 0/5/30 s.

**@⁠adrianmjim** on GitHub · 2026-11-27 06:26 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/356#issuecomment-7211535800) Tested on RX 7900 XT (RDNA3), driver 32.0.32029.2010, Windows 11 26300, Rust 1.98.1, release builds. Base a-publier 4eb6cfd vs 4eb6cfd + this PR (d18892a), merged locally. Real game install: 109 files, 93 of them within MAX_FILE (2 GiB), 41.25 GiB in total. `--jobs 4`, fresh shader cache for each run. Walk only (`translate --warm <list>` with a list that matches no hash, so nothing is translated): - `VICTORY_WARM_SECONDS=0`: PR 0.07 s, no game file read. Base 46.4 s, reads all 41.25 GiB. - 5 s: PR stops at 5.4-5.9 s after reading 5.1 GiB. Base 42-44 s, reads everything. - 30 s: PR 30.2 s, 28.0 GiB. Base 39.9 s, reads everything. - Unlimited: both read 41.25 GiB in 189 read ops. Neither prints "stopped at the time limit". - With the 5 s and 30 s budgets the PR stops 0.2-0.9 s after the deadline, while the file in flight finishes (files are up to 2 GiB). With translation (`translate --warm all`): - Unlimited: base 373.8 s, PR 381.8 s, one run each. The gap is smaller than the 36-46 s spread of the walk alone between runs. Same counts on both: 25985 found, 25790 translated, 195 do not translate. The two shader caches are byte-identical (25790 entries). - 30 s: PR exits at 30.3 s, base at 47.1 s. Both translated the same 29 shaders. Every entry matches the unlimited cache byte for byte. - On this install the walk only reaches the first 1000 shaders after 44-51 s. A 30 s budget is mostly spent reading shader-free files that come first in walk order. This is not caused by this PR. Other notes: - `warm()` doc says "nothing is made on the GPU". No pipelines are made (the cache only gets `shaders/`). But `precompile` opens the host D3D12 device, and `probe_view_limit` creates descriptor heaps on it. This line is unchanged by the PR. Not tested: the full test suite on the merge, other GPUs, and budgets other than 0/5/30 s.
Keep the worker-count and deadline tests and clarify when the host device is used.
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/356/head:github-bot/gh-356'
git switch 'github-bot/gh-356'

Merge

Merge the changes and update on Forgejo.
git switch 'a-publier'
git merge --no-ff 'github-bot/gh-356'
git switch 'github-bot/gh-356'
git rebase 'a-publier'
git switch 'a-publier'
git merge --ff-only 'github-bot/gh-356'
git switch 'github-bot/gh-356'
git rebase 'a-publier'
git switch 'a-publier'
git merge --no-ff 'github-bot/gh-356'
git switch 'a-publier'
git merge --squash 'github-bot/gh-356'
git switch 'a-publier'
git merge --ff-only 'github-bot/gh-356'
git switch 'a-publier'
git merge 'github-bot/gh-356'
git push origin 'a-publier'
This discussion has been locked. Commenting is limited to contributors.
No description provided.