Avoid spawning and joining a thread for each single-container file in offline shader precompile #1861
Labels
No labels
AMD
audio
bug
confirmed
crash
cutscene
dlss
documentation
duplicate
enhancement
fixed-on-main
frame-generation
good first issue
help wanted
input
INTEL
invalid
lighting
linux-proton
memory
needs-info
needs-logs
needs-rebase
NVIDIA
performance
pr-diagnostics
pr-docs
pr-feature
pr-fix
pr-performance
pr-refactor
pr-tests
question
RAYTRACING
rendering
report
series-s
shaders
spam
startup
upstream
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/trustno1-coder--VIctory-NVIDIA#1861
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@NotADonky43 on GitHub · 2026-11-29 00:54 UTC · original
On
f9dfb76f, translate::precompile scans input files sequentially and starts a new thread even when a file contains exactly one shader. Disjoint multi-process builds pay this per file too. I will test running that work on the calling thread while keeping parallel workers for multi-container inputs, including cache-hit, failure and deduplication cases. Scope: apps/victory/src/translate.rs only. #1313 changes file exclusions / pipeline preload, not this scheduling decision.@NotADonky43 on GitHub · 2026-11-29 00:54 UTC · original
/claim
@github-actions[bot] on GitHub · 2026-11-29 00:54 UTC · original
Please attach both logs from the run that went wrong. Without them we can only guess. Paste
%LOCALAPPDATA%into the address bar of File Explorer to get there.%LOCALAPPDATA%\victory\logs\: the newestvictory-nvidia-play-<date>-<time>-<number>.log(fromvictory.exe) orvictory-nvidia-<date>-<time>.log(from the script launcher). The window shows its path at the start, on the lineLog: ....%LOCALAPPDATA%\VIctory\data\7952987A\crashes.log, and, if there is one from that run, the newestvictory-<date>-<time>-<number>.crash.login%LOCALAPPDATA%\VIctory\data\7952987A\temp\.Also say which GPU, Windows version (10 or 11)
@kalberts0089-hash on GitHub · 2026-11-29 08:01 UTC · original · edited 2026-11-29 08:19 UTC
The issue is still present on main. I measured it, and running the single-worker case inline roughly halves the per-file overhead on this machine.
Code at
e1f2eb6.apps/victory/src/translate.rs:463-489(precompile) callssources(&data)and thenstd::thread::scopewiththreads.min(jobs.len())workers for every file. A file with exactly one container, including one whose container was already seen, gets a thread spawned and joined.translate::warm(translate.rs:193-197) andtranslate::run(translate.rs:297-301) do the same thing, but they are outside the scope stated here.Micro-benchmark. This is a standalone loop of
thread::scope+ 1 spawn + join against the same loop inline, 20,000 iterations, on an RTX 4070 Ti box running Windows 11 with other builds going. Two separate runs:End to end with
victory shaders. I used synthetic input: 5000 files of 4 KiB, each holding the same 32-byte part-less DXBC (the 2nd to 5000th hit the dedup path), withVICTORY_HOMEpointed at a scratch dir. I compared main against a build whereworkers == 1calls the worker closure directly,workers > 1keeps the scoped threads andworkers == 0does nothing. 10 interleaved runs each:That works out to about 130 us saved per single-container file. A second set of 6 interleaved runs later gave main 1044-1809 ms and patched 539-971 ms.
Behaviour check. I used one dir with a 4-container file that contains an internal duplicate, a single-container file duplicating one of those, a single new container, and a file with no container. Over 5 runs each, both builds print the same counts:
The
e.g.hash changes from run to run in both builds, because the 4-container file still goes to parallel workers and whichever failure is recorded first is shown. I could not test the success and cache-hit paths with real DXIL because I can't run the game here.translate.rshas no test forprecompile.The patch I measured:
One more point, which I have not measured on real data: files are still scanned one after another, and parallelism exists only inside a file. On an install made mostly of single-container files, this change removes the spawn cost but still translates one shader at a time.