GPU: allow configuring pipeline worker count via VICTORY_PIPELINE_WORKERS #2750

Closed
0xKaji wants to merge 1 commit from upstream-pr/2752 into main
0xKaji commented 2026-11-25 19:40:15 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by 0xKaji on 2026-11-25T19:40:15Z.


Adds an optional VICTORY_PIPELINE_WORKERS environment variable (clamped to 1..=16) to override the default pipeline worker thread count ((cpus / 2).clamp(2, 8)) in crates/victory-gpu/src/pipeline/make.rs.

Motivation

  • Helps #2124 (single-thread pipeline compilation workaround on AMD RDNA4).
  • Significantly reduces peak memory pressure and avoids NVIDIA shader-compiler crashes/kills (exit=137) on 16 GiB RAM systems under Linux + Wine + vkd3d-proton when entering the world.

A/B Measurements (Linux / Wine 11.22 / vkd3d-proton / RTX 3060 8 GB / 16 GiB RAM, Series S + #2112 + #2723, 4-min run)

VICTORY_PIPELINE_WORKERS Outcome Time Peak RSS
Default (8) exit=137 ~60 s 11.20 GiB
2 exit=137 ~72 s 10.14 GiB
1 exit=124 (full 4 min) 240 s 8.51 GiB (~4.9 GiB available)

Verification

  • Added unit test worker_count_respects_override_and_clamps.
  • Verified with cargo xwin check --workspace --target x86_64-pc-windows-msvc --locked and cargo xwin test -p victory-gpu --no-run --target x86_64-pc-windows-msvc --locked.
<!-- greyfinch-sync:Marvisak/VIctory:issue:6612279652 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2752). Originally posted by [0xKaji](https://github.com/0xKaji) on 2026-11-25T19:40:15Z. --- Adds an optional `VICTORY_PIPELINE_WORKERS` environment variable (clamped to `1..=16`) to override the default pipeline worker thread count (`(cpus / 2).clamp(2, 8)`) in `crates/victory-gpu/src/pipeline/make.rs`. ### Motivation - Helps #2124 (single-thread pipeline compilation workaround on AMD RDNA4). - Significantly reduces peak memory pressure and avoids NVIDIA shader-compiler crashes/kills (`exit=137`) on 16 GiB RAM systems under Linux + Wine + vkd3d-proton when entering the world. ### A/B Measurements (Linux / Wine 11.22 / vkd3d-proton / RTX 3060 8 GB / 16 GiB RAM, Series S + #2112 + #2723, 4-min run) | `VICTORY_PIPELINE_WORKERS` | Outcome | Time | Peak RSS | |---|---|---|---| | Default (`8`) | `exit=137` | ~60 s | 11.20 GiB | | `2` | `exit=137` | ~72 s | 10.14 GiB | | `1` | **`exit=124` (full 4 min)** | 240 s | **8.51 GiB** (~4.9 GiB available) | ### Verification - Added unit test `worker_count_respects_override_and_clamps`. - Verified with `cargo xwin check --workspace --target x86_64-pc-windows-msvc --locked` and `cargo xwin test -p victory-gpu --no-run --target x86_64-pc-windows-msvc --locked`.
kotekompotek commented 2026-11-25 20:06:26 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-25T20:03:02Z.


Heads up: this overlaps #2250 (VICTORY_PIPELINE_THREADS), which the maintainer triage already marked merge-candidate. Differences: #2250 also applies the knob to worker count when --jobs isn't given, and its 0 value selects calling-thread compilation (the strongest workaround for the amdxc64 crash in #2124) - your 1..=16 clamp silently maps 0 to 1, losing that diagnostic. The A/B data here (peak RSS vs workers, exit=137 on 16 GiB under vkd3d) is genuinely useful extra motivation either PR could cite. Whichever lands, it may be worth keeping the 0=synchronous semantics.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7173117517 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2752#issuecomment-7173117517). Originally posted by [kotekompotek](https://github.com/kotekompotek) on 2026-11-25T20:03:02Z. --- Heads up: this overlaps #2250 (VICTORY_PIPELINE_THREADS), which the maintainer triage already marked merge-candidate. Differences: #2250 also applies the knob to worker count when --jobs isn't given, and its 0 value selects calling-thread compilation (the strongest workaround for the amdxc64 crash in #2124) - your 1..=16 clamp silently maps 0 to 1, losing that diagnostic. The A/B data here (peak RSS vs workers, exit=137 on 16 GiB under vkd3d) is genuinely useful extra motivation either PR could cite. Whichever lands, it may be worth keeping the 0=synchronous semantics.
upstream-sync closed this pull request 2026-11-25 21:02:46 +00:00
fuzeofficlal commented 2026-11-25 21:03:03 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T20:14:29Z.


Reviewed and verified ab8d3768 on Windows 11 against main (13f91ca).

Code review & overlap note

  • worker_count preserves the default (cpus / 2).clamp(2, 8) when unset or unparseable and clamps parsed overrides into 1..=16 (avoiding thread-count explosion on huge inputs like "100000"). Minor note: invalid or out-of-range values are clamped/ignored silently without a tracing::warn!.
  • Overlap with #2250 (already triage: merge candidate, VICTORY_PIPELINE_THREADS): both configure pipeline::make::queue worker threads, with a behavioral difference on 0 (#2250 uses 0 for synchronous/calling-thread compilation, whereas #2752 clamps 0 to 1). Worth coordinating env-var naming and 0 semantics with #2250.

Verification (Windows 11, rustc 1.98.1 MSVC)

  • VICTORY_D3D12_WARP=1 cargo test -p victory-gpu --features diagnostics --lib --locked -- pipeline::: 17 passed, 0 failed (including worker_count_respects_override_and_clamps).
  • cargo clippy -p victory-gpu --all-targets --locked -- -D warnings: 0 warnings; cargo xtask policy: 184 files ok; clean git merge-tree against 13f91ca and #2746.
<!-- greyfinch-sync:Marvisak/VIctory:comment:7173381867 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2752#issuecomment-7173381867). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-25T20:14:29Z. --- Reviewed and verified `ab8d3768` on Windows 11 against `main` (`13f91ca`). ### Code review & overlap note - `worker_count` preserves the default `(cpus / 2).clamp(2, 8)` when unset or unparseable and clamps parsed overrides into `1..=16` (avoiding thread-count explosion on huge inputs like `"100000"`). Minor note: invalid or out-of-range values are clamped/ignored silently without a `tracing::warn!`. - **Overlap with `#2250`** (already `triage: merge candidate`, `VICTORY_PIPELINE_THREADS`): both configure `pipeline::make::queue` worker threads, with a behavioral difference on `0` (`#2250` uses `0` for synchronous/calling-thread compilation, whereas `#2752` clamps `0` to `1`). Worth coordinating env-var naming and `0` semantics with `#2250`. ### Verification (Windows 11, `rustc 1.98.1` MSVC) - `VICTORY_D3D12_WARP=1 cargo test -p victory-gpu --features diagnostics --lib --locked -- pipeline::`: **17 passed, 0 failed** (including `worker_count_respects_override_and_clamps`). - `cargo clippy -p victory-gpu --all-targets --locked -- -D warnings`: **0 warnings**; `cargo xtask policy`: **184 files ok**; clean `git merge-tree` against `13f91ca` and `#2746`.
0xKaji commented 2026-11-25 21:03:12 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by 0xKaji on 2026-11-25T20:23:32Z.


Thanks @kotekompotek and @fuzeofficlal for the review and the heads-up! Closing this PR in favor of #2250 (VICTORY_PIPELINE_THREADS), and I've posted the 16 GiB / NVIDIA A/B measurements there.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7173602090 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2752#issuecomment-7173602090). Originally posted by [0xKaji](https://github.com/0xKaji) on 2026-11-25T20:23:32Z. --- Thanks @kotekompotek and @fuzeofficlal for the review and the heads-up! Closing this PR in favor of #2250 (`VICTORY_PIPELINE_THREADS`), and I've posted the 16 GiB / NVIDIA A/B measurements there.

Pull request closed

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!2750
No description provided.