build: make_game leaves one CPU thread free by default, as the launcher's Automatic does #932

Merged
HumanBean merged 1 commit from HumanBean/Longshot:build/jobs-leave-one-free into main 2026-11-15 21:37:15 +00:00
Owner

Type: build · Risk: low · Tested on: Linux, game-free checks · Needs: none

Why

A build from the command line started one compiler per CPU thread, so for its whole length the PC had no thread to spare:
the desktop, a browser or a game in another window lagged while it built. The launcher's Automatic already leaves one
thread free (SystemInfo.AutomaticWorkers: every thread but one). Builds without the launcher now do the same. I searched
the tracker (forge.py issue list) and found no issue for this.

What changed

make_game.py starts at most one compiler per CPU thread but one when neither --jobs nor LONGSHOT_JOBS names a
number, never fewer than one. The free-memory gate (issue 418) still holds any of them back as before.

  • build: default_jobs() in nx2/make_game.py returns max(1, threads - 1); its log line says so.
  • tests: tests/test_default_jobs.py cuts default_jobs out of the source and runs it with the CPU count stubbed
    (24, 16, 8, 4, 2, 1 and unknown).
  • docs: docs/development.md, the LONGSHOT_JOBS row.

Measurements

Nothing to measure in the game: a build script's default, held by its new check (at most one compiler fewer, so the compile stage takes at most about 1/23 longer on 24 threads).

Flags and settings

LONGSHOT_JOBS / --jobs keep their meaning; only the automatic default changes.

Flag What it is Before this PR After this PR Effect Helps / doesn't help / untested Recommendation
LONGSHOT_JOBS unset (automatic) compilers at once one per CPU thread one per CPU thread but one (at least 1) one thread stays free for the desktop while it builds helps responsiveness; costs at most one compiler's share on for everyone (it is the default)

Testing

Tested: On Linux (24 threads), with --jobs 23: python -I -B tests/test_default_jobs.py (3 tests OK) and
python -I -B tests/run_all.py build_log default_jobs (2 passed). I also ran the whole suite with the Vulkan, SPIR-V and
VMA headers given: 588 passed, 20 failed, 22 skipped. The same 20 fail on another branch without this change. They
don't run default_jobs (sandboxed sockets and disk, and checks that need tools not on this PC): test_linux_update,
test_make_game_cache, test_lift_cleanup_error, test_bake_portability, test_crt_options, test_crash_dialog,
test_env_on, test_appimage_player_build, test_linux_preflight, test_missing_nup, test_options_budget_once,
test_pipeline_states, test_mods_size_table, test_pipeline_tour, test_readback_late, test_replay_write_order,
test_nonuniform_image_arrays, test_vk_pgo, test_walk_key, test_vk_occlusion_queries.

Not tested: A full game build with the new default. The function only picks a number, and that number goes to
build.py --jobs as an explicit --jobs would.

Must be tested: None.

Risks

What could break: Nothing functional. A build with no --jobs on a 2-thread PC now compiles one file at a time
instead of two.

Turning it off: LONGSHOT_JOBS=<threads> for the old count, or revert the commit.

Compatibility: Nothing changes for a player: the launcher passes its own number, and the AppImage's builds now
leave one thread free too.

Checklist

Everyone

  • One topic.
  • The title is a Conventional Commit (type(scope): description) of the status line's type.
  • Why gives the reason plainly and links the issues that fit (the tracker searched).
  • Measurements has a verdict, or one line saying why there is nothing to measure.
  • Testing names what was tested, what wasn't, and what must still be tested, where and how.
  • Rebased on current main.
  • python -I -B tests/run_all.py passes (any failure that also fails on main is named).
  • No game files, dumps, build output or generated files.
  • third_party/ untouched (a new folder with a PROVENANCE.md instead).
  • The license is OK: GPL-3.0-or-later, nothing incompatible and nothing decompiled.

When it applies

  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.
  • Switches documented (docs/development.md; the README for a menu row) and shipped at their recommended value.
  • A game-free test added for the fix, failing on main and passing here.
  • Docs updated.

🤖 Generated with Claude Code

**Type:** build · **Risk:** low · **Tested on:** Linux, game-free checks · **Needs:** none ## Why A build from the command line started one compiler per CPU thread, so for its whole length the PC had no thread to spare: the desktop, a browser or a game in another window lagged while it built. The launcher's Automatic already leaves one thread free (`SystemInfo.AutomaticWorkers`: every thread but one). Builds without the launcher now do the same. I searched the tracker (`forge.py issue list`) and found no issue for this. ## What changed `make_game.py` starts at most one compiler per CPU thread but one when neither `--jobs` nor `LONGSHOT_JOBS` names a number, never fewer than one. The free-memory gate (issue 418) still holds any of them back as before. - build: `default_jobs()` in `nx2/make_game.py` returns `max(1, threads - 1)`; its log line says so. - tests: `tests/test_default_jobs.py` cuts `default_jobs` out of the source and runs it with the CPU count stubbed (24, 16, 8, 4, 2, 1 and unknown). - docs: `docs/development.md`, the `LONGSHOT_JOBS` row. ## Measurements Nothing to measure in the game: a build script's default, held by its new check (at most one compiler fewer, so the compile stage takes at most about 1/23 longer on 24 threads). ### Flags and settings `LONGSHOT_JOBS` / `--jobs` keep their meaning; only the automatic default changes. | Flag | What it is | Before this PR | After this PR | Effect | Helps / doesn't help / untested | Recommendation | |---|---|---|---|---|---|---| | `LONGSHOT_JOBS` unset (automatic) | compilers at once | one per CPU thread | one per CPU thread but one (at least 1) | one thread stays free for the desktop while it builds | helps responsiveness; costs at most one compiler's share | on for everyone (it is the default) | ## Testing **Tested:** On Linux (24 threads), with `--jobs 23`: `python -I -B tests/test_default_jobs.py` (3 tests OK) and `python -I -B tests/run_all.py build_log default_jobs` (2 passed). I also ran the whole suite with the Vulkan, SPIR-V and VMA headers given: 588 passed, 20 failed, 22 skipped. The same 20 fail on another branch without this change. They don't run `default_jobs` (sandboxed sockets and disk, and checks that need tools not on this PC): `test_linux_update`, `test_make_game_cache`, `test_lift_cleanup_error`, `test_bake_portability`, `test_crt_options`, `test_crash_dialog`, `test_env_on`, `test_appimage_player_build`, `test_linux_preflight`, `test_missing_nup`, `test_options_budget_once`, `test_pipeline_states`, `test_mods_size_table`, `test_pipeline_tour`, `test_readback_late`, `test_replay_write_order`, `test_nonuniform_image_arrays`, `test_vk_pgo`, `test_walk_key`, `test_vk_occlusion_queries`. **Not tested:** A full game build with the new default. The function only picks a number, and that number goes to `build.py --jobs` as an explicit `--jobs` would. **Must be tested:** None. ## Risks **What could break:** Nothing functional. A build with no `--jobs` on a 2-thread PC now compiles one file at a time instead of two. **Turning it off:** `LONGSHOT_JOBS=<threads>` for the old count, or revert the commit. **Compatibility:** Nothing changes for a player: the launcher passes its own number, and the AppImage's builds now leave one thread free too. ## Checklist ### Everyone - [x] One topic. - [x] The title is a Conventional Commit (`type(scope): description`) of the status line's type. - [x] Why gives the reason plainly and links the issues that fit (the tracker searched). - [x] Measurements has a verdict, or one line saying why there is nothing to measure. - [x] Testing names what was tested, what wasn't, and what must still be tested, where and how. - [x] Rebased on current `main`. - [x] `python -I -B tests/run_all.py` passes (any failure that also fails on `main` is named). - [x] No game files, dumps, build output or generated files. - [x] `third_party/` untouched (a new folder with a `PROVENANCE.md` instead). - [x] The license is OK: GPL-3.0-or-later, nothing incompatible and nothing decompiled. ### When it applies - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. - [x] Switches documented (docs/development.md; the README for a menu row) and shipped at their recommended value. - [x] A game-free test added for the fix, failing on `main` and passing here. - [x] Docs updated. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
build: make_game leaves one CPU thread free by default, as the launcher's Automatic does
Some checks failed
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been skipped
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been skipped
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been skipped
Third-party parts / The same as upstream (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 3s
Website / Website on Cloudflare (pull_request_target) Has been skipped
CI / Workflow lint (actionlint) (pull_request) Successful in 7s
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 5s
Third-party parts / As their notes say (pull_request) Successful in 9s
PR description / Description follows the template (pull_request_target) Successful in 4s
4746176e08
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
Owner

Measurements as one line: a build default, held by tests/test_default_jobs.py

Measurements as one line: a build default, held by tests/test_default_jobs.py
HumanBean changed title from WIP: build: make_game leaves one CPU thread free by default, as the launcher's Automatic does to build: make_game leaves one CPU thread free by default, as the launcher's Automatic does 2026-11-15 21:24:56 +00:00
HumanBean deleted branch build/jobs-leave-one-free 2026-11-15 21:37:16 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
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.

Dependencies

No dependencies set

Reference
MagicBeanDev/Longshot!932
No description provided.