WIP: fix(dev): a timed run's noise names the queue's jobs that ran beside it #2187

Draft
dyst wants to merge 1 commit from dyst/Longshot:fix/queue-noise-beside into main
Member

Summary

A timed run's history keeps how busy the rest of the PC was, so a noisy measurement shows. Two of those readings, the CPU pressure and the load, come from Linux alone and are always 0 on Windows. And the queue's own other jobs running beside a timed run were never noted. A light job starts beside a timing one. In two dev.py ab series for #2185, another session's runtime builds ran beside three runs and prepared shaders on the GPU: those runs gave 27.9, 29.1 and 41.1 fps against 65 to 72, with the noise all zeros.

The noise now names each other queue job active while the timed run ran ("jobs_beside": ["rt-pr1937 (light)"]), on every system. The run's line then says the PC was busy while it measured.

Read first: Noise and _keep_apart in scripts/devtools/jobqueue.py.

Testing

Tested: not run yet.

  • Checks: tests/test_job_queue.py has a case for the record's new field. Not run yet.

Still to test:

  • Windows, any GPU: a timing job with a light job of another name started beside it, expecting dev.py queue history to name that job under jobs_beside, and the run's line to say the PC was busy (by hand)

Measurements

Nothing to measure: what the queue records, not how a run goes.

Risks

A timed run with a job beside it now ends with the "busy while it measured" line; nothing is refused or moved. Reverting 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. Not run yet.
  • mise run test passes (any failure that also fails on main is named). Not run yet.
  • 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

  • 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

## Summary A timed run's history keeps how busy the rest of the PC was, so a noisy measurement shows. Two of those readings, the CPU pressure and the load, come from Linux alone and are always 0 on Windows. And the queue's own other jobs running beside a timed run were never noted. A light job starts beside a timing one. In two `dev.py ab` series for #2185, another session's runtime builds ran beside three runs and prepared shaders on the GPU: those runs gave 27.9, 29.1 and 41.1 fps against 65 to 72, with the noise all zeros. The noise now names each other queue job active while the timed run ran (`"jobs_beside": ["rt-pr1937 (light)"]`), on every system. The run's line then says the PC was busy while it measured. Read first: `Noise` and `_keep_apart` in `scripts/devtools/jobqueue.py`. ## Testing **Tested:** not run yet. - **Checks:** `tests/test_job_queue.py` has a case for the record's new field. Not run yet. **Still to test:** - Windows, any GPU: a timing job with a light job of another name started beside it, expecting `dev.py queue history` to name that job under `jobs_beside`, and the run's line to say the PC was busy (by hand) ## Measurements Nothing to measure: what the queue records, not how a run goes. ## Risks A timed run with a job beside it now ends with the "busy while it measured" line; nothing is refused or moved. Reverting 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. Not run yet. - [ ] `mise run test` passes (any failure that also fails on `main` is named). Not run yet. - [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] 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)
fix(dev): a timed run's noise names the queue's jobs that ran beside it
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
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 10s
CI / Website build and checks (pull_request) Failing after 23s
Website / Website on Cloudflare (pull_request_target) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 26s
PR description / Description follows the template (pull_request_target) Successful in 36s
Third-party parts / As their notes say (pull_request) Successful in 13s
CI / Workflow lint (actionlint) (pull_request) Successful in 44s
a77e22141f
A timed run's history kept the PC's CPU pressure and load, both read from Linux alone, and the builds outside the queue.
On Windows the first two are always 0, and the queue's own jobs beside a timed run were never noted: a light job starts
beside a timing one, and two series of dev.py ab had runs spoiled by another session's runtime builds (their shader
preparation took the GPU; 27.9 and 29.1 fps against 65 to 68) with the noise all zeros. The noise now names each other job
active while the timed run ran ("name (mode)"), on every system, and the run's line says the PC was busy when there was one.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
dazemc left a comment

On Windows β€” the platform the PR's own #2185 series is about β€” jobs_beside is always empty: the only code that fills it is inside _keep_apart, and that thread is started only if timing_cpus and not common.WINDOWS.

The collection gate (blocker). Noise.beside is added in _keep_apart's for t in read_tickets(...) loop. run() starts _keep_apart only if timing_cpus and not common.WINDOWS. On Windows common.WINDOWS is true; on a Linux PC with one L3 domain (or no sysfs) l3_domains() leaves timing_cpus None and the queue itself prints "no pinning". In both, no sampler runs: jobs_beside is [], noise.strays is empty and cpu_pressure/load are 0, so the run line's if noise.strays or noise.beside or noise.cpu_pressure > 20 never fires and dev.py queue history shows a false quiet. The PR's Windows Still-to-test ("expecting dev.py queue history to name that job under jobs_beside") cannot pass today. Noise's docstring and the PR's "seen on every system" are false. Fix: collect the read_tickets/beside (and heavy_procs if wanted) independent of the pinning thread and the OS β€” the pinning, PSI and load are the Linux-only parts; start the sampler whenever cpu == "quiet" and let _keep_apart skip the procs.pin calls when timing_cpus is None/Windows. Add a test that drives a fake queue directory through the sampler, not just record().

The verdict does not use it. scripts/devtools/ab.py has no noise/jobs_beside; the dev.py ab write-up (results.json/measurements.md) reads the game's log, not the queue history. The only consumers are jobqueue.run's "busy" line and dev.py queue history. So a noisy A/B still writes up a verdict; the #2185 series would still produce a gain/loss unless someone separately reads the queue history. If the field is meant to protect measurements, ab.py's run_one/verdict should read the queue history's noise and mark or refuse the run; the PR's Risks says "nothing is refused", which is the gap.

Sampling. _keep_apart polls every 2 s (while not stop.wait(2)); beside is the set of tickets active at a sample, not an exact interval overlap. A light/shared job shorter than the poll, or one starting/ending inside the first or last 2 s, is not named. The run history has started/ended, so an exact overlap could be computed if the finished tickets' times were kept. The PR's "active while the timed run ran" is approximate. (The Windows/no-pinning gate matters more.)

What "noise" measures now. cpu_pressure_max (Linux PSI cpu some), load_max (Linux load), builds_outside (heavy processes outside the queue, the strays), and the new jobs_beside (the queue's own active jobs as name (mode), e.g. rt-pr1937 (light)). builds_outside and jobs_beside are distinct: outside the queue vs the queue's own. On Linux with pinning, read_tickets adds every active ticket whatever its cpu/affinity, so a build (heavy), shared or light job β€” including one pinned to other_cpus β€” is named; the timing run's own ticket is excluded (pid != me["pid"]), waiting jobs aren't named (they didn't run), and the timing job's child processes are not tickets. That part is right.

The test. NoiseBeside.test_record only checks n.record()["jobs_beside"] after n.beside.update(...); it doesn't run run()/_keep_apart, mock Windows or a no-pinning Linux, or exercise the 2 s sample. I ran it: on the head tests/test_job_queue.py is 26 tests OK (5 skipped); on a2dc5385 with only the head's test it is 26 run, 1 error (KeyError: 'jobs_beside'). The red is just the missing field; a real Windows run would still be quiet and the test would still pass.

What remains. A sampler that runs on Windows/no-pinning; the A/B verdict reading the queue noise; an exact overlap or a documented sampling window; a collection test; and the Windows dev.py queue history run (the PR's Still to test) β€” which the current code would fail. I ran only the game-free test.

No approval, no claim.

**On Windows β€” the platform the PR's own #2185 series is about β€” `jobs_beside` is always empty: the only code that fills it is inside `_keep_apart`, and that thread is started only `if timing_cpus and not common.WINDOWS`.** **The collection gate (blocker).** `Noise.beside` is added in `_keep_apart`'s `for t in read_tickets(...)` loop. `run()` starts `_keep_apart` only `if timing_cpus and not common.WINDOWS`. On Windows `common.WINDOWS` is true; on a Linux PC with one L3 domain (or no sysfs) `l3_domains()` leaves `timing_cpus` None and the queue itself prints "no pinning". In both, no sampler runs: `jobs_beside` is `[]`, `noise.strays` is empty and `cpu_pressure`/`load` are 0, so the `run` line's `if noise.strays or noise.beside or noise.cpu_pressure > 20` never fires and `dev.py queue history` shows a false quiet. The PR's Windows Still-to-test ("expecting `dev.py queue history` to name that job under `jobs_beside`") cannot pass today. `Noise`'s docstring and the PR's "seen on every system" are false. Fix: collect the `read_tickets`/`beside` (and `heavy_procs` if wanted) independent of the pinning thread and the OS β€” the pinning, PSI and load are the Linux-only parts; start the sampler whenever `cpu == "quiet"` and let `_keep_apart` skip the `procs.pin` calls when `timing_cpus` is None/Windows. Add a test that drives a fake queue directory through the sampler, not just `record()`. **The verdict does not use it.** `scripts/devtools/ab.py` has no `noise`/`jobs_beside`; the `dev.py ab` write-up (`results.json`/`measurements.md`) reads the game's log, not the queue history. The only consumers are `jobqueue.run`'s "busy" line and `dev.py queue history`. So a noisy A/B still writes up a verdict; the #2185 series would still produce a gain/loss unless someone separately reads the queue history. If the field is meant to protect measurements, `ab.py`'s `run_one`/verdict should read the queue history's `noise` and mark or refuse the run; the PR's Risks says "nothing is refused", which is the gap. **Sampling.** `_keep_apart` polls every 2 s (`while not stop.wait(2)`); `beside` is the set of tickets active at a sample, not an exact interval overlap. A light/shared job shorter than the poll, or one starting/ending inside the first or last 2 s, is not named. The `run` history has `started`/`ended`, so an exact overlap could be computed if the finished tickets' times were kept. The PR's "active while the timed run ran" is approximate. (The Windows/no-pinning gate matters more.) **What "noise" measures now.** `cpu_pressure_max` (Linux PSI cpu some), `load_max` (Linux load), `builds_outside` (heavy processes outside the queue, the `strays`), and the new `jobs_beside` (the queue's own active jobs as `name (mode)`, e.g. `rt-pr1937 (light)`). `builds_outside` and `jobs_beside` are distinct: outside the queue vs the queue's own. On Linux with pinning, `read_tickets` adds every active ticket whatever its `cpu`/affinity, so a build (`heavy`), `shared` or `light` job β€” including one pinned to `other_cpus` β€” is named; the timing run's own ticket is excluded (`pid != me["pid"]`), waiting jobs aren't named (they didn't run), and the timing job's child processes are not tickets. That part is right. **The test.** `NoiseBeside.test_record` only checks `n.record()["jobs_beside"]` after `n.beside.update(...)`; it doesn't run `run()`/`_keep_apart`, mock Windows or a no-pinning Linux, or exercise the 2 s sample. I ran it: on the head `tests/test_job_queue.py` is **26 tests OK (5 skipped)**; on `a2dc5385` with only the head's test it is **26 run, 1 error** (`KeyError: 'jobs_beside'`). The red is just the missing field; a real Windows run would still be quiet and the test would still pass. **What remains.** A sampler that runs on Windows/no-pinning; the A/B verdict reading the queue noise; an exact overlap or a documented sampling window; a collection test; and the Windows `dev.py queue history` run (the PR's Still to test) β€” which the current code would fail. I ran only the game-free test. No approval, no claim.
Owner

See #2403

See https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2403
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
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 10s
CI / Website build and checks (pull_request) Failing after 23s
Website / Website on Cloudflare (pull_request_target) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 26s
PR description / Description follows the template (pull_request_target) Successful in 36s
Third-party parts / As their notes say (pull_request) Successful in 13s
CI / Workflow lint (actionlint) (pull_request) Successful in 44s
This pull request has changes conflicting with the target branch.
  • scripts/devtools/jobqueue.py
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'fix/queue-noise-beside:dyst-fix/queue-noise-beside'
git switch 'dyst-fix/queue-noise-beside'
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
3 participants
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!2187
No description provided.