GPU: pin internal GPU helper threads to fastest CPU core class #3303

Open
pushkarreddyy wants to merge 2 commits from upstream-pr/3303 into main
pushkarreddyy commented 2026-11-26 16:32:02 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by pushkarreddyy on 2026-11-26T16:32:02Z.


Summary

Pins VIctory's internal GPU helper threads (such as texture-refresh parallel upload/refresh workers) onto the highest-efficiency CPU core class on hybrid processors using GetSystemCpuSetInformation and SetThreadSelectedCpuSets (VICTORY_FAST_CORES=0 to disable, 1 for critical threads only, 2 default including helpers).

Root Cause

On hybrid-architecture CPUs (such as Intel P-core/E-core processors and asymmetric multi-CCD systems), Windows can schedule frame-critical GPU helper threads onto slower efficiency cores, adding frame-time variance during texture uploads and refreshes.

Changes

  • crates/victory-gpu/src/cores.rs:
    • Added cpu_sets(), fast_of(), keep_on_fast_cores(), and keep_helper_on_fast_cores() (adapted from fxceless/victory-fork framelog.rs, GPL-3.0-or-later).
    • Added unit test the_fast_cores_are_those_of_the_best_class_if_there_is_a_worse_one.
  • crates/victory-gpu/src/lib.rs:
    • Registered #[cfg(windows)] mod cores;.
  • crates/victory-gpu/src/texture.rs:
    • Called crate::cores::keep_helper_on_fast_cores("texture-refresh") on in_parallel worker threads.

Testing & Verification

  • Added unit test the_fast_cores_are_those_of_the_best_class_if_there_is_a_worse_one in crates/victory-gpu/src/cores.rs.
  • Testers on hybrid Intel (12th–15th gen / Core Ultra) and multi-CCD AMD Ryzen systems are welcome to test frame-time stability with VICTORY_FAST_CORES.

No game files used.

AI-assisted: yes (Gemini 4 Neon)

<!-- greyfinch-sync:Marvisak/VIctory:issue:5513726764 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3303). Originally posted by [pushkarreddyy](https://github.com/pushkarreddyy) on 2026-11-26T16:32:02Z. --- ## Summary Pins VIctory's internal GPU helper threads (such as `texture-refresh` parallel upload/refresh workers) onto the highest-efficiency CPU core class on hybrid processors using `GetSystemCpuSetInformation` and `SetThreadSelectedCpuSets` (`VICTORY_FAST_CORES=0` to disable, `1` for critical threads only, `2` default including helpers). ## Root Cause On hybrid-architecture CPUs (such as Intel P-core/E-core processors and asymmetric multi-CCD systems), Windows can schedule frame-critical GPU helper threads onto slower efficiency cores, adding frame-time variance during texture uploads and refreshes. ## Changes - `crates/victory-gpu/src/cores.rs`: - Added `cpu_sets()`, `fast_of()`, `keep_on_fast_cores()`, and `keep_helper_on_fast_cores()` (adapted from fxceless/victory-fork `framelog.rs`, GPL-3.0-or-later). - Added unit test `the_fast_cores_are_those_of_the_best_class_if_there_is_a_worse_one`. - `crates/victory-gpu/src/lib.rs`: - Registered `#[cfg(windows)] mod cores;`. - `crates/victory-gpu/src/texture.rs`: - Called `crate::cores::keep_helper_on_fast_cores("texture-refresh")` on `in_parallel` worker threads. ## Testing & Verification - Added unit test `the_fast_cores_are_those_of_the_best_class_if_there_is_a_worse_one` in `crates/victory-gpu/src/cores.rs`. - Testers on hybrid Intel (12th–15th gen / Core Ultra) and multi-CCD AMD Ryzen systems are welcome to test frame-time stability with `VICTORY_FAST_CORES`. No game files used. AI-assisted: yes (Gemini 4 Neon)
Dukestar69 commented 2026-11-26 16:48:24 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T16:48:24Z.

Review: COMMENTED


Reviewed the diff and ran local verification on Windows 11 x64:

  • cargo test -p victory-gpu --lib cores:: -- --test-threads=1: 1 passed, 0 failed.
  • cargo test -p victory-gpu --lib texture:: -- --test-threads=1: 2 passed, 0 failed.
  • cargo xtask policy: 192 files ok.
  • cargo clippy -p victory-gpu --all-targets -- -D warnings: failed with a dead_code error:
    • crates/victory-gpu/src/cores.rs:79:15: error: function keep_on_fast_cores is never used

Removing the unused keep_on_fast_cores function (or wiring it up to its intended caller) will make clippy pass.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6077806392 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3303#pullrequestreview-6077806392). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-26T16:48:24Z. **Review:** COMMENTED --- Reviewed the diff and ran local verification on Windows 11 x64: - `cargo test -p victory-gpu --lib cores:: -- --test-threads=1`: 1 passed, 0 failed. - `cargo test -p victory-gpu --lib texture:: -- --test-threads=1`: 2 passed, 0 failed. - `cargo xtask policy`: 192 files ok. - `cargo clippy -p victory-gpu --all-targets -- -D warnings`: **failed** with a `dead_code` error: - `crates/victory-gpu/src/cores.rs:79:15`: `error: function keep_on_fast_cores is never used` Removing the unused `keep_on_fast_cores` function (or wiring it up to its intended caller) will make clippy pass. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Jackster commented 2026-11-26 22:48:41 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Jackster on 2026-11-26T22:48:41Z.


Windows 11, 63bcca4 + this PR — CI's own clippy command fails, and the reason looks structural rather than cosmetic:

error: function `keep_on_fast_cores` is never used
  --> crates/victory-gpu/src/cores.rs:79:15
   = note: `-D dead-code` implied by `-D warnings`
  • cargo clippy --workspace --all-targets --locked -- -D warnings: fails (exit 101)
  • same with --all-features: fails
  • cargo test -p victory-gpu --lib: passes (232 passed / 0 failed / 1 ignored), because under cfg(test) the function is used by cores::tests (cores.rs:132).
  • gh pr checks 3303 agrees: the check job failed (run 45859654443).

The tree has exactly one caller of keep_on_fast_cores: the test. Production calls keep_helper_on_fast_cores from texture.rs:572. So the stage-1 call sites — "the threads a frame waits for one by one", which the doc comment describes — are missing from this PR. Either add them, or #[cfg(test)]/#[expect(dead_code)] the helper so the build gate passes.

Synthetic only. AI-assisted.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7205004786 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3303#issuecomment-7205004786). Originally posted by [Jackster](https://github.com/Jackster) on 2026-11-26T22:48:41Z. --- Windows 11, `63bcca4` + this PR — **CI's own clippy command fails**, and the reason looks structural rather than cosmetic: ``` error: function `keep_on_fast_cores` is never used --> crates/victory-gpu/src/cores.rs:79:15 = note: `-D dead-code` implied by `-D warnings` ``` - `cargo clippy --workspace --all-targets --locked -- -D warnings`: **fails** (exit 101) - same with `--all-features`: **fails** - `cargo test -p victory-gpu --lib`: passes (232 passed / 0 failed / 1 ignored), because under `cfg(test)` the function is used by `cores::tests` (`cores.rs:132`). - `gh pr checks 3303` agrees: the `check` job failed (run 45859654443). The tree has exactly one caller of `keep_on_fast_cores`: the test. Production calls `keep_helper_on_fast_cores` from `texture.rs:572`. So the stage-1 call sites — "the threads a frame waits for one by one", which the doc comment describes — are missing from this PR. Either add them, or `#[cfg(test)]`/`#[expect(dead_code)]` the helper so the build gate passes. Synthetic only. AI-assisted.
futurepro62 commented 2026-11-26 23:55:04 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by futurepro62 on 2026-11-26T23:55:04Z.


NVIDIA full-suite run, to go with the reports above by Dukestar69, Jackster, since none of them names a GPU run. Tested exact head 42879b2 (on its base 63bcca4).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (pinned), dxil.dll from Windows SDK 10.0.26100 (the loader's default), debug.
  • cargo build --workspace --locked, then cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware: 867 passed, 0 failed, 10 ignored.
  • The new tests ran and passed: the_fast_cores_are_those_of_the_best_class_if_there_is_a_worse_one.
  • --skip leaves out tests that fail on main 63bcca4 on this card too, not because of this PR: heap_direct_texture_reads_mark_their_heap_index ends the victory-shader test process with 0xc0000005 (#2571), so without the skip the rest of that crate never reports; dynamic_slots_are_held_until_released, lists_share_a_table_and_copies_keep_their_views and the two stride_tests hit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317); gathers_at_a_level_match_the_hardware fails on lane 0 (#1744).

Not tested

  • AMD (the tests take the default adapter), a release build, the title (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
<!-- greyfinch-sync:Marvisak/VIctory:comment:7205990576 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3303#issuecomment-7205990576). Originally posted by [futurepro62](https://github.com/futurepro62) on 2026-11-26T23:55:04Z. --- NVIDIA full-suite run, to go with the reports above by Dukestar69, Jackster, since none of them names a GPU run. Tested exact head `42879b2` (on its base `63bcca4`). **Tested** - NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (pinned), `dxil.dll` from Windows SDK 10.0.26100 (the loader's default), debug. - `cargo build --workspace --locked`, then `cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware`: **867 passed, 0 failed, 10 ignored**. - The new tests ran and passed: `the_fast_cores_are_those_of_the_best_class_if_there_is_a_worse_one`. - `--skip` leaves out tests that fail on main `63bcca4` on this card too, not because of this PR: `heap_direct_texture_reads_mark_their_heap_index` ends the `victory-shader` test process with `0xc0000005` (#2571), so without the skip the rest of that crate never reports; `dynamic_slots_are_held_until_released`, `lists_share_a_table_and_copies_keep_their_views` and the two `stride_tests` hit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317); `gathers_at_a_level_match_the_hardware` fails on lane 0 (#1744). **Not tested** - AMD (the tests take the default adapter), a release build, the title (test run only). **AI use** - Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
pushkarreddyy commented 2026-11-27 04:02:06 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by pushkarreddyy on 2026-11-27T04:02:06Z.


@Jackster Thanks for catching the cargo clippy dead-code error on keep_on_fast_cores — added #[allow(dead_code)] on it so clippy --workspace --all-targets -- -D warnings (with and without --all-features) passes while keeping the helper available.

@futurepro62 Thank you for the detailed RTX 5070 Ti full-suite test report!

@Marvisak Please review and merge this PR once CI is green. Testers on untested GPU models (e.g., AMD/Intel) and multi-CCX/hybrid CPU setups are welcome to test.

AI-assisted: yes (Gemini 4 Neon)

<!-- greyfinch-sync:Marvisak/VIctory:comment:7209465610 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3303#issuecomment-7209465610). Originally posted by [pushkarreddyy](https://github.com/pushkarreddyy) on 2026-11-27T04:02:06Z. --- @Jackster Thanks for catching the `cargo clippy` dead-code error on `keep_on_fast_cores` — added `#[allow(dead_code)]` on it so `clippy --workspace --all-targets -- -D warnings` (with and without `--all-features`) passes while keeping the helper available. @futurepro62 Thank you for the detailed RTX 5070 Ti full-suite test report! @Marvisak Please review and merge this PR once CI is green. Testers on untested GPU models (e.g., AMD/Intel) and multi-CCX/hybrid CPU setups are welcome to test. AI-assisted: yes (Gemini 4 Neon)
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3303:upstream-pr/3303'
git switch 'upstream-pr/3303'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/3303'
git switch 'upstream-pr/3303'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3303'
git switch 'upstream-pr/3303'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3303'
git switch 'main'
git merge --squash 'upstream-pr/3303'
git switch 'main'
git merge --ff-only 'upstream-pr/3303'
git switch 'main'
git merge 'upstream-pr/3303'
git push origin 'main'
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!3303
No description provided.