Repository navigation
Conversation
wide_threads() cached only VICTORY_WIDE_THREADS; without it, every call asked std::thread::available_parallelism() again, and queued, wide_each and wide_each_scoped call it one to three times per spread of work on the submitting thread. On Windows that call asks the system for the process's affinity and job limits: 862 to 998 ns a call on a Ryzen 9 5900X, 2 ns cached (200,000 calls a sample, release build). The helper threads are started once with this count, so a count that changed later would not match them anyway.
tphira612
force-pushed
the
perf/wide-threads-once
branch
from
November 30, 2026 01:15
7d04a35 to
4667446
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What it changes
wide_threads()inshadow.rscached onlyVICTORY_WIDE_THREADS. Without it (the default), every call askedstd::thread::available_parallelism()again.queued,wide_eachandwide_each_scopedcall it one to three times per spread of work, on the submitting thread. On Windows that call asks the system for the process's affinity and job limits each time.The count is now worked out once in the
OnceLock. The value, the clamps and the switch are unchanged. The helper threads are started once with this count anyway.How it was tested
cargo test --locked -p victory-gpu --lib:shadow::wide_testspass. Two failures are not from this change:every_switch_of_the_translator_is_in_the_keyalso fails onmain, anda_change_is_saved_at_once_however_the_game_was_startedpasses when run alone.cargo build --release --locked -p victoryandcargo xtask policy --stagedpass. Clippy is clean invictory-gpu; it stops onvictory-shadererrors already onmain(fixed by ci: fix workspace clippy -D warnings failures across default and diagnostics builds #3560, ci: fix default and diagnostics Clippy failures #3530, chore(ci): fix workspace clippy -D warnings, diagnostics build, and stale tests on main #3385).