feat(build): builds leave some CPU threads free and run at low priority, with an opt-in for every thread at full speed #235
No reviewers
Labels
No labels
area/build
area/install
area/saves
area/tooling
area/ui
area/updates
ci: approved
good first issue
gpu/amd
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
platform/linux
platform/steam-deck
platform/windows
priority
critical
priority
high
priority
low
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/LongshotLauncher!235
Loading…
Reference in a new issue
No description provided.
Delete branch "HumanBean/LongshotLauncher:feat/build-cpu-headroom"
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?
Players say their PC is close to unusable while the launcher builds or updates the game: one took five minutes to take a screenshot (#148), and another saw 100% CPU through an update with Build workers on Automatic (#163). Builds now leave some threads free and run at low priority, so the desktop and other programs come first. Anyone who wants the fastest build can still choose every thread.
Fixes #148
Fixes #163
What I found
LauncherSettings.BuildWorkers, passed asLONGSHOT_JOBSon Windows and--jobson Linux). Automatic meant "every thread but one" (SystemInfo.AutomaticWorkers). The player in #201 who "lowered the build core count to about 12" was using this setting.--update), started exactly like a build. The launcher has no separate copy or update method; its own copying (game files hard-linked throughLONGSHOT_ROMFS_FROM, shader caches kept) is file I/O, not CPU work.os.cpu_count()instead of--jobs: reading the .nup (nx2/chunks.py), discovery and the shader preparation. So the read and copy steps of an update can fill every thread whatever Build workers says. The other fix is low process priority, which covers everything the build starts.Summary
SystemInfo.KeptFree). It keeps 1 thread free on 2–4 threads, 2 on 5–8, and a quarter from 9 threads up, so a 16-thread CPU runs 12 compilers (the 5700X3D in #163, and the "about 12" from #201), 24 threads run 18, and a single thread keeps nothing back. A fixed one or two threads is too little headroom on a big CPU. A quarter costs little: threads past the physical cores add less to a build (the forecast already scales bythreads^0.85), and the compilers also wait on memory and the disk.MakeGameRun.Lower, set as soon as make_game.py starts, before it starts any compiler):BELOW_NORMAL_PRIORITY_CLASS, which the processes it starts inherit.BelowNormal), which its processes and threads inherit.--checkrun does too.BuildWorkers = 0(LauncherSettings.EveryThread); an older launcher reads 0 as Automatic, so a shared or downgraded settings file is safe.BuildThreadsnow goes throughSystemInfo.Workers, so the step 2 estimate,BuildProgressandBuildClockuse the threads the build will actually run with. On 16 threads it says about 19 min on Automatic and about 16 min on Every thread (screenshots below). The clock still corrects from the measured pace once the build runs.workers automatic (12, low priority).scripts/translations.pyreports nothing broken.Testing
python -I tests/test_launcher_core.py: 2608 checks passed (Linux, outside the sandbox). New checks:KeptFree,AutomaticWorkers,WorkersandLowPriorityfor each setting and thread count, and the forecast being longer on Automatic than on Every thread (ScreenChecks).sh, which prints its ownniceand a child's; both are 10 or more. A run at full speed keeps the test process's own nice (ScreenChecks.RunChecks).MakeGameCommand.ForandForCheckcarryLowPriority: on by default, off for a full-speed request (Program.cs).settings.jsonkeepsEveryThread, and a negative value becomes Automatic.LAUNCHER=$PWD python -I ../Tooling/tests/test_release.py: 42 run, 3 fail:test_the_bump,test_the_next_stable,test_check_tag_against_the_published_releases. These 3 fail on unchanged main too, and this PR doesn't touch release code.dotnet build LongshotLauncher.slnx -warnaserror: 0 warnings.tools/screenshotsscenessettings-workers,settings-workers-choicesandsettings-workers-every, rendered withDOTNET_PROCESSOR_COUNT=16. The pictures are in the first comment.Not tested:
BELOW_NORMALinheritance is Windows' documented behaviour, but I couldn't run it here.🤖 Generated with Claude Code
Screenshots from
tools/screenshots(the real step 2 view, Windows, rendered as a 16-thread PC withDOTNET_PROCESSOR_COUNT=16).Automatic (the default): 12 of 16 at once, with 4 threads left free. About 19 min.
The dropdown: Automatic, then Every thread, fastest, then a number.
Every thread, fastest: all 16 at normal priority. About 16 min.
a3ffaaf72227482159fa