gpu: pipeline: honor --jobs and CPU count in repair_shaders instead of 768 MiB/proc RAM cap #465
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/lobomfz--VIctory-xmem!465
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-465"
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?
@lucamzanon on GitHub · 2026-12-04 14:06 UTC · original
lucamzanon:xmem/13-repair-shaders-jobs→main· +38 −3 · 2 files · 1 commits · openProblem
When
victory warm --jobs Nrunsknown::repair_shaders(&dir), it currently ignores the--jobsargument and callssuper::prepared::jobs(), which budgets 768 MiB per child pipeline-compiler process on top of an 8 GiB reserve:When
run.sh playlaunches Wine insidesystemd-run -p MemoryMax=...(e.g.MemoryMax=9846Mon Linux), Wine reports ~8–9 GiB of available physical RAM, soprepared::jobs()collapses to 1. As a result,repair_shaders()spawns only 1 worker thread even when--jobs 8was passed — turning a ~25,000-shader repair pass from ~35 seconds into ~8–10 minutes on a single core (observed live viaps -Lonvictory.exe warm --jobs 8).Unlike child pipeline compiler processes,
repair_shaders()runs lightweight in-process shader translation threads.Change
jobs: Option<usize>fromapps/victory/src/warm.rsintoknown::repair_shaders(&dir, jobs).repair_workers_from(jobs, env_jobs, cpus):--jobs N(clamped1..=64), elseVICTORY_WARM_JOBS(clamped1..=64), elsestd::thread::available_parallelism()(clamped1..=16).Ok(())ifranges.is_empty().pipeline::known::tests::repair_workers_honors_jobs_then_env_then_cpus.Verification
cargo check --locked -p victory(Windows MSVC cross-compile): clean.victory-gpuunit tests under Wine (pipeline::known::tests): 6/6 pass.cargo clippy --locked --no-deps --all-targets: 0 warnings inknown.rs, no new warnings inwarm.rs.@Kal0s-design on GitHub · 2026-12-04 14:49 UTC · original
Checked
2dd0bfa. The count logic is fine and the tests pass on native Windows (MSVC, not Wine). One thing I'm not sure the change covers, plus a few small notes.What changes and where
ca97da2together with repair_shaders, and I found no reason given for it beyond the doc comment, which talks about processes (prepared.rs:327-330).warm --thesechildren (warm.rs:417) return at warm.rs:54-55 before reaching repair_shaders, so the new default doesn't get multiplied per child process.Pre-game path
run.rs:148 calls prepare_start, which spawns
warm --jobs <prepared::jobs()>(prepared.rs:349-352). So under run.sh play the child already gets the RAM-capped number as an explicit --jobs. If that number is 1 under MemoryMax, the PR still runs repair on 1 thread there. The only difference from main is that the child uses the parent's value instead of computing it again. Where did the --jobs 8 in your ps -L run come from? From a manualvictory warm --jobs 8, or did the parent pick 8 and the child then got less? VICTORY_WARM_JOBS is empty in run.conf.default (run.conf.default:288), and when set it already applied to repair on main through prepared.rs:333. If the goal is to fix the play case, the fix probably needs to go in prepared::warm or in how repair picks its default, not only in honoring --jobs.Memory
The only path that really changes by default is a standalone warm with no --jobs, which is what run.sh warm runs (
warm --used, run.sh:275). That's where the PR does give its speedup, because the RAM term can no longer drop the count to 1. But there the repair threads go from the RAM-capped half of the cores to all cores up to 16, and the memory guard is gone. I didn't measure how much memory a translation thread uses, and I didn't run a repair. There is a precedent though.victory shadersruns the same shader_cache::precompile on every logical core with no memory limit (translate.rs:449-450, d3d12x.rs:42, shader_cache.rs:165), so threads with no memory cap are already accepted for this work. The count tops out at 16 by default and 64 when set explicitly. The same available_parallelism call was already used on main (prepared.rs:339). Whatever it returns on a host with processor groups or restricted affinity, the result is clamped to 16 by default, so it can't push the count up.Small things
Tests (native Windows, MSVC)
AI-assisted: yes
@lucamzanon on GitHub · 2026-12-05 04:31 UTC · original
Thanks @Kal0s-design for verifying on native Windows MSVC!
To answer your question about
--jobs 8in ourps -Lcapture: on our 46 GB Linux desktop, the parentvictory.exe runcomputedprepared::jobs() = 8(cpus/2) and spawnedvictory.exe warm --jobs 8, while inside the childrepair_shaders()ignored--jobs 8and recomputedprepared::jobs()under thesystemd-run -p MemoryMax=9846Mcgroup where Wine reported ~8–9 GiB free, collapsing to 1 thread.You also raise a great point for hosts where even the parent sees low free RAM under
MemoryMaxand passes--jobs 1towarm(sinceprepared::jobs()caps child PSO processes at 768 MiB each): in that caserepair_shaders()would still get1from--jobs 1unlessrepairignores the process RAM cap orprepare_startpasses separate counts. That said, honoring--jobsfirst already fixes the parent-passes-N / child-recomputes-1 bug and standalonerun.sh warm(warm --used), while keeping explicit--jobsrespected.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.