fix(dev): rt and base no longer hold the base's lock while their jobs wait in the queue #3197

Merged
HumanBean merged 2 commits from HumanBean/Longshot:fix/dev-base-lock-queue into main 2026-12-04 20:07:38 +00:00
Owner

Summary

Two dev.py jobs on one PC could deadlock the whole job queue. On 2026-12-04 it stood still for about 23 minutes, with
six jobs waiting, until one was cancelled by hand:

  1. An rt held the shared base's lock and queued its job, which waited behind a timed run.
  2. The timed run waited for the running builds to end.
  3. One of those builds was a dev.py queue run ... -- sh -c "dev.py rt ...", whose rt waited for the base's lock.

dev.py rt (and rt --empty) now take the base's lock inside each job, once it has its slot, through
dev.py base-locked <base> -- CMD. Nothing holds the lock while a job waits for a slot. dev.py base held its lock the
same way around its build; outside a job it now queues the whole of itself, and takes the lock once it runs. This is the
rule packs.builder already keeps for the builder's compile.

Read first: locked_cmd, cmd_base and cmd_rt in scripts/devtools/build.py.

Testing

Tested: CachyOS (Linux 7.3.3). tests/test_dev_build.py and tests/test_dev_packs.py: four tests fail at the test
commit and pass with the fix; they check that the lock is free at every queue call and that base-locked holds it for
its command. test_dev_ab, test_dev_disk and test_job_queue pass. Two tests in test_dev_packs.py asserted the
lock held around the queue calls; they now assert that each job's command takes this base's lock and that none is held
while queued.

mise run test: 881 passed, 13 skipped, 12 failed. The failures are in renderer, UI, title and builder checks, none in
the dev tools; they are being run on main @ 8c058ddb to name which fail there too (a comment follows).

Still to test:

  • This PC: a real dev.py rt and rt --empty through the queue, expecting both runtimes made (queued; a comment
    follows).
  • Windows: dev.py rt, expecting the runtime made, with base-locked holding the lock under msvcrt (by hand).

Measurements

Nothing to measure: dev tooling, no change to the game or its build's output.

Risks

A checkout without this change still holds the lock while it waits, so the circle can still close between an old
checkout and a new one until each is up to date. Between rt's two jobs (the build and the shaders' preparation) the
lock is now let go, so another job on the same base may run between them. rt still marks the base used before queuing,
so dev.py disk --prune leaves it while a job waits. A revert is enough.

Checklist

Ready for review

  • One topic, on current main; the title is a Conventional Commit.
  • Tested on my own PC, in the game for a change the game runs, as Testing says. (the real rt run is still queued)
  • mise run test passes (any failure that also fails on main is named). (the run on main is still queued)
  • Measured against main, or Measurements says why there is nothing to measure.
  • No game files, build output or hand-edited generated files; third_party/ untouched; nothing GPL-incompatible.

When it applies

  • A fix: a game-free test that fails on main and passes here.
  • A check under tests/ that reads changed source is updated, not weakened.
  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.

Ready to merge

  • Everything in Still to test has run, its results in Tested.
  • Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers").
  • Approved in review, every comment answered.
  • CI passes on the head; on current main, measured again or a comment says why the numbers still hold.

🤖 Generated with Claude Code

https://claude.ai/code/session_017vw8e3Wd6AA2ofRgZt7Lqm

## Summary Two `dev.py` jobs on one PC could deadlock the whole job queue. On 2026-12-04 it stood still for about 23 minutes, with six jobs waiting, until one was cancelled by hand: 1. An `rt` held the shared base's lock and queued its job, which waited behind a timed run. 2. The timed run waited for the running builds to end. 3. One of those builds was a `dev.py queue run ... -- sh -c "dev.py rt ..."`, whose `rt` waited for the base's lock. `dev.py rt` (and `rt --empty`) now take the base's lock inside each job, once it has its slot, through `dev.py base-locked <base> -- CMD`. Nothing holds the lock while a job waits for a slot. `dev.py base` held its lock the same way around its build; outside a job it now queues the whole of itself, and takes the lock once it runs. This is the rule `packs.builder` already keeps for the builder's compile. Read first: `locked_cmd`, `cmd_base` and `cmd_rt` in `scripts/devtools/build.py`. ## Testing **Tested:** CachyOS (Linux 7.3.3). `tests/test_dev_build.py` and `tests/test_dev_packs.py`: four tests fail at the test commit and pass with the fix; they check that the lock is free at every queue call and that `base-locked` holds it for its command. `test_dev_ab`, `test_dev_disk` and `test_job_queue` pass. Two tests in `test_dev_packs.py` asserted the lock held around the queue calls; they now assert that each job's command takes this base's lock and that none is held while queued. `mise run test`: 881 passed, 13 skipped, 12 failed. The failures are in renderer, UI, title and builder checks, none in the dev tools; they are being run on `main @ 8c058ddb` to name which fail there too (a comment follows). **Still to test:** - This PC: a real `dev.py rt` and `rt --empty` through the queue, expecting both runtimes made (queued; a comment follows). - Windows: `dev.py rt`, expecting the runtime made, with `base-locked` holding the lock under msvcrt (by hand). ## Measurements Nothing to measure: dev tooling, no change to the game or its build's output. ## Risks A checkout without this change still holds the lock while it waits, so the circle can still close between an old checkout and a new one until each is up to date. Between `rt`'s two jobs (the build and the shaders' preparation) the lock is now let go, so another job on the same base may run between them. `rt` still marks the base used before queuing, so `dev.py disk --prune` leaves it while a job waits. A revert is enough. ## Checklist ### Ready for review - [x] One topic, on current `main`; the title is a Conventional Commit. - [ ] Tested on my own PC, in the game for a change the game runs, as Testing says. (the real `rt` run is still queued) - [ ] `mise run test` passes (any failure that also fails on `main` is named). (the run on `main` is still queued) - [x] Measured against `main`, or Measurements says why there is nothing to measure. - [x] No game files, build output or hand-edited generated files; `third_party/` untouched; nothing GPL-incompatible. ### When it applies - [x] A fix: a game-free test that fails on `main` and passes here. - [x] A check under `tests/` that reads changed source is updated, not weakened. - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. ### Ready to merge - [ ] Everything in Still to test has run, its results in Tested. - [ ] Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers"). - [ ] Approved in review, every comment answered. - [ ] CI passes on the head; on current `main`, measured again or a comment says why the numbers still hold. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_017vw8e3Wd6AA2ofRgZt7Lqm
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e3Wd6AA2ofRgZt7Lqm
fix(dev): rt and base take the base's lock inside their jobs, not while a job waits for its slot
Some checks failed
CI / What the change needs (pull_request) Successful in 9s
CI / Third-party parts and guide screenshots (pull_request) Successful in 13s
PR description / Title and description (pull_request_target) Failing after 7s
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Successful in 18s
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Failing after 1m19s
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Failing after 9m38s
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Successful in 10m32s
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Successful in 11m46s
CI / Website build and checks (pull_request) Failing after 40s
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Failing after 14m23s
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Failing after 47m6s
048c1a1028
dev.py rt held the shared base's lock around the jobs it queued. With a timed run queued ahead, the holder waited behind it, the timed run waited for the running builds, and a build job whose own dev.py rt wanted the lock waited for the holder: none went on. Each job now takes the lock once it runs (dev.py base-locked); dev.py base runs whole as a job.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e3Wd6AA2ofRgZt7Lqm
HumanBean changed title from WIP: fix(dev): rt and base no longer hold the base's lock while their jobs wait in the queue to fix(dev): rt and base no longer hold the base's lock while their jobs wait in the queue 2026-12-04 20:07:33 +00:00
HumanBean deleted branch fix/dev-base-lock-queue 2026-12-04 20:07:38 +00:00
Author
Owner

The two checks still pending when this merged:

  • A real run, on main @ 7c9055d9 (which has this change), CachyOS: dev.py rt and dev.py rt --empty through the queue both exited 0 and made their runtimes. During rt, a step waited for another holder of the base from inside its job, then went on.
  • The mise run test failures: 11 of the 12 fail on main @ 8c058ddb too, run there one by one (test_dlssg, test_present_geometry_trace, test_ui_renderer, test_present_image_free, test_no_game_title, test_vk_draw_overhead_lean, test_sync_watch_event, test_turf_budget, test_pass_barrier, test_present_held_image, test_present_acquire_ahead). The twelfth is test_lifter, whose the_repository_s_lock_and_the_table_agree was already failing on main earlier the same day; I did not run it again on 8c058ddb.

Windows has not run it.

The two checks still pending when this merged: - **A real run, on `main @ 7c9055d9`** (which has this change), CachyOS: `dev.py rt` and `dev.py rt --empty` through the queue both exited 0 and made their runtimes. During `rt`, a step waited for another holder of the base from inside its job, then went on. - **The `mise run test` failures:** 11 of the 12 fail on `main @ 8c058ddb` too, run there one by one (`test_dlssg`, `test_present_geometry_trace`, `test_ui_renderer`, `test_present_image_free`, `test_no_game_title`, `test_vk_draw_overhead_lean`, `test_sync_watch_event`, `test_turf_budget`, `test_pass_barrier`, `test_present_held_image`, `test_present_acquire_ahead`). The twelfth is `test_lifter`, whose `the_repository_s_lock_and_the_table_agree` was already failing on `main` earlier the same day; I did not run it again on `8c058ddb`. Windows has not run it.
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!3197
No description provided.