DirectStorage: worker count and priority switches (VICTORY_DSTORAGE_WORKERS, VICTORY_DSTORAGE_PRIORITY) #402

Open
github-bot wants to merge 1 commit from github-bot/gh-402 into a-publier AGit
Owner

@⁠Esteban-V on GitHub · 2026-11-27 00:02 UTC · original
Esteban-V:perf/dstorage-workers → a-publier · +34 −3 · 1 files · 1 commits · open

The DirectStorage scheduler starts one worker per logical processor (available_parallelism, crates/victory-hle/src/modules/dstorage.rs:631), so 24 on a 12-core/24-thread CPU. The workers inflate zlib and unpack BCPack on the CPU at normal priority, inside an above-normal process, and in streaming bursts they can take every core away from the frame-critical threads. Nothing could change the count or the priority. This adds two opt-in switches for both.

  • VICTORY_DSTORAGE_WORKERS=n: start n workers, clamped to 1..=64. Unset (or not a number): one per logical processor, as before.
  • VICTORY_DSTORAGE_PRIORITY=below: each worker sets itself to THREAD_PRIORITY_BELOW_NORMAL when it starts. Unset: as before.
  • The count comes from a small pure worker_count(asked, processors), like pipeline/make.rs::worker_count, with a unit test. The startup log line now also prints below.
  • Nothing else depends on the worker count. Files::new keeps its handle count and a worker picks its handle by this_thread() % n, so any count works. One worker still drains the queue, because Lanes::start starts a read whenever nothing is staged (covered by staging_bounds_compressed_bytes_in_flight).
  • Defaults are unchanged.

To A/B: VICTORY_DSTORAGE_WORKERS=8 to 12, with and without VICTORY_DSTORAGE_PRIORITY=below, against the default, comparing frame times during streaming (driving through the city). Please also check load times: runtime.rs records that starving loading once made loads take 40 to 60 s instead of 28 to 33 s, which is why both switches are opt-in.

Testing

  • Windows CI (windows-latest): Clippy, default tests and diagnostics tests pass (run).
  • Type-checked and clippy-clean for x86_64-pc-windows-msvc on a macOS host (cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-msvc -- -D warnings, default and --all-features).
  • Unit test worker_count_follows_the_processors_and_the_switch added.
**@⁠Esteban-V** on GitHub · 2026-11-27 00:02 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/402) `Esteban-V:perf/dstorage-workers` → `a-publier` · +34 −3 · 1 files · 1 commits · open The DirectStorage scheduler starts one worker per logical processor (`available_parallelism`, `crates/victory-hle/src/modules/dstorage.rs:631`), so 24 on a 12-core/24-thread CPU. The workers inflate zlib and unpack BCPack on the CPU at normal priority, inside an above-normal process, and in streaming bursts they can take every core away from the frame-critical threads. Nothing could change the count or the priority. This adds two opt-in switches for both. - `VICTORY_DSTORAGE_WORKERS=n`: start `n` workers, clamped to 1..=64. Unset (or not a number): one per logical processor, as before. - `VICTORY_DSTORAGE_PRIORITY=below`: each worker sets itself to `THREAD_PRIORITY_BELOW_NORMAL` when it starts. Unset: as before. - The count comes from a small pure `worker_count(asked, processors)`, like `pipeline/make.rs::worker_count`, with a unit test. The startup log line now also prints `below`. - Nothing else depends on the worker count. `Files::new` keeps its handle count and a worker picks its handle by `this_thread() % n`, so any count works. One worker still drains the queue, because `Lanes::start` starts a read whenever nothing is staged (covered by `staging_bounds_compressed_bytes_in_flight`). - Defaults are unchanged. To A/B: `VICTORY_DSTORAGE_WORKERS=8` to `12`, with and without `VICTORY_DSTORAGE_PRIORITY=below`, against the default, comparing frame times during streaming (driving through the city). Please also check load times: `runtime.rs` records that starving loading once made loads take 40 to 60 s instead of 28 to 33 s, which is why both switches are opt-in. ## Testing - Windows CI (`windows-latest`): Clippy, default tests and diagnostics tests pass ([run](https://github.com/Esteban-V/VIctory-Belobug-AMD/actions/runs/45916899133)). - Type-checked and clippy-clean for `x86_64-pc-windows-msvc` on a macOS host (`cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-msvc -- -D warnings`, default and `--all-features`). - Unit test `worker_count_follows_the_processors_and_the_switch` added.
The scheduler starts one worker per logical processor, at normal
priority in an above-normal process; in streaming bursts they inflate
and unpack on every core, next to the frame threads. Nothing could
change that.

VICTORY_DSTORAGE_WORKERS=n starts n workers (1 to 64); unset, one per
logical processor as before. VICTORY_DSTORAGE_PRIORITY=below puts each
worker below normal priority; unset, as before. Files keep their handle
count: a worker picks its handle by its number modulo that count, so any
worker count works, and one worker still drains the queue (a read starts
when nothing is staged). Defaults are unchanged.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 00:59:15 +00:00
Author
Owner

@⁠MamaLeVrai on GitHub · 2026-11-27 01:23 UTC · original

Tested on an RX 6950 XT (RDNA 2), driver 32.0.21045.29003, Windows 11 build 26300, Rust 1.98.1, release. At 9a19fd3: cargo test --release -p victory-hle --lib 163 passed, 0 failed, 2 ignored.

AI-assisted (Claude Code); no game data.

**@⁠MamaLeVrai** on GitHub · 2026-11-27 01:23 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/402#issuecomment-7207246553) Tested on an RX 6950 XT (RDNA 2), driver 32.0.21045.29003, Windows 11 build 26300, Rust 1.98.1, release. At `9a19fd3`: `cargo test --release -p victory-hle --lib` 163 passed, 0 failed, 2 ignored. AI-assisted (Claude Code); no game data.
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/402/head:github-bot/gh-402'
git switch 'github-bot/gh-402'

Merge

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