fix(queue): a timed run's noise is its job's scope's stalls, read once systemd has moved the command there, not the runner's cgroup's #2611
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/mods
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
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
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!2611
Loading…
Reference in a new issue
No description provided.
Delete branch "Jiro113/Longshot:fix/queue-noise-scope"
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?
Summary
A timed run (
dev.py queue run … --mode timing,timing-cpu,profile) samples every 2 s what its own processesstalled on, and marks the run NOISY past
NOISY's limits. Since #2409 it reads those stalls from the job's cgroup, thesystemd scope
run()puts the command in. On Linux it read the wrong cgroup in both cases:systemd-runworks):run()readcgroup_of(child.pid)once, right afterPopenreturned. At that moment the child issystemd-runitself, still in the runner's cgroup:systemd-run --scopeasks systemd for the scope, waits until systemd has moved it there, and only then runs the command. The runtherefore sampled the runner's cgroup, which is its terminal's and holds whatever else runs there, and never its own
scope. It still marked the samples as its own (
"own": true).LONGSHOT_QUEUE_SCOPE=0, or nosystemd-run): the command stays in the runner's cgroup, andthat cgroup was taken as the job's own.
In both cases a timed run was judged on the stalls of a cgroup that is not its own. It missed what slowed it down
elsewhere on the PC, and counted what ran in its terminal.
Now
Noise.followkeeps the command's pid and its scope's unit name. Each sample reads the command's cgroup againuntil it is that scope, then keeps it. Until then, and for a run without a scope, the PC's stalls are sampled, with
"own": false, as the code's own notes already said. No code readsown, which is there for whoever reads thesamples, so a run whose first sample is the PC's and the rest its scope's is fine. The unit name comes from one function,
job_unit, whichrun()'ssystemd-run --unitandend_job'ssystemctl killnow share.Read first:
scripts/devtools/jobqueue.py,Noise.followandNoise.sample, then the lines afterPopeninrun().docs/dev/developing.mdsays which stalls a timed run samples.Flags and settings: none.
Testing
Tested: Windows 11 (build 26300), Python 3.13, through the PC's job queue (
dev.py queue run … --mode build),mainbeing201f8868e. No game run and no measurement: the change is in the queue's noise sampling, which has noPSI on Windows. Three new cases in
NoiseOfARundriverun()itself on any OS, with a made-up command (pid 999999)and made-up cgroups. They patch
Popen,cgroup_of,pressureand the reads of the PC. The runner's cgroup hasstalls of 2.0, the scope that
--unitnames 3.0, and the PC 1.0. systemd moves the command into the scope by the timerun()waits for it, or only after the first sample.main, all three fail for the bug's reason:test_a_runs_own_stalls_are_its_scopes: the first sample read the runner's cgroup,(2.0, 2.0, 2.0)against(3.0, 3.0, 3.0).test_the_pcs_stalls_until_systemd_has_moved_it:(True, 2.0)against the PC's(False, 1.0).test_without_a_scope_the_pcs_stalls:ownwas true.run()'s old line put back (the cgroup read at once), all three fail again.test_the_pcs_stalls_until_systemd_has_moved_itfails.tests/test_job_queue.pyin full, in the queue, on this branch: 43 tests, 2 failing, 6 skipped. The two aretest_a_build_outside_the_queueandtest_a_pid_used_again_or_another_namespace_is_not_it, which fail the sameway on
mainon Windows when the suite runs in the queue; #2610 fixes them. With #2610's changes underneath: 43tests, none failing, 6 skipped.
tests/run_all.py --changed origin/mainin the queue, on this branch: 5 checks, 4 passing (test_oot_state_tap.py,test_dev_packs.py,byte_compile_tracked.py,test_driver_cache_env.py),test_job_queue.pyfailing for the twocases above. With #2610's changes too: 6 checks, all passing.
tests/run_all.pyin full, in the queue (Windows, 32 at once), with this change and #2610's: 794 passed, 13failed, 52 skipped. The 13 fail the same way on
main201f8868e. I reran them alone on both (--exact) and gotthe same 41 failure lines, but for temporary paths:
test_auto_handheld,test_bug_report,test_builder_channel,test_coverage_run,test_dev_ab,test_dev_build,test_dev_migrate,test_game_menu_mouse_buttons,test_input_movie,test_oot_menu_mouse,test_pads_after_menu,test_parity_gates,test_run_all_mingw. These are this PC's Windows failures, among them a recent clangwarning under
-Werrorand checks that run only on Linux. They are unrelated to this change.ruff check(0.12.0, as pinned) on both Python files: passed.Still to test:
python3 -c "import subprocess, time; p = subprocess.Popen(['systemd-run', '--user', '--scope', '--quiet', '--', 'sleep', '3']); a = open('/proc/%d/cgroup' % p.pid).read(); time.sleep(1); print(a, open('/proc/%d/cgroup' % p.pid).read())". Expect the first line to name theshell's cgroup and the second a
run-….scope.python -I scripts/dev.py queue run noise-check --mode timing-cpu --noise ~/noise.jsonl -- sleep 6. Expect"own": truein the samples of~/noise.jsonl: the command'scgroup was found to be its
longshot-job-noise-check-….scope."own": falsewould mean systemd names thescope's folder otherwise.
Measurements
Nothing to measure: the change is in how the queue judges a measurement's noise, not in the game or in what is measured.
Risks
Linux only: Windows has no PSI, and the sampling there is unchanged. A timed run's noise record reads the PC's stalls
until systemd has moved the command into its scope. That takes a few milliseconds, and the first sample comes 2 s in. A
run without a scope reads the PC's stalls throughout. Those are higher than a cgroup's when the PC is busy, so such runs
can be marked NOISY more often than before. That is the intent: a busy PC is noise. A revert is enough to undo it.
The new cases were not run on Linux here, so CI's Linux run is the first. There they read
/procfor real:procs.treeandprocs.proc_startof pid 999999, reads only. Nothing in them signals, pins or writes to a process.No second agent has reviewed it cold yet.
Checklist
Ready for review
main; the title is a Conventional Commit.mise run testpasses (any failure that also fails onmainis named).main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.When it applies
mainand passes here.tests/that reads changed source is updated, not weakened.Assisted-by:/Co-Authored-By:trailers.Ready to merge
main, measured again or a comment says why the numbers still hold.🤖 Generated with Claude Code
WIP: fix(queue): a timed run's noise is its job's scope's stalls, read once systemd has moved the command there, not the runner's cgroup'sto fix(queue): a timed run's noise is its job's scope's stalls, read once systemd has moved the command there, not the runner's cgroup'sdc4d1aa88c242f84e59c@review
242f84e59cce477d72bbce477d72bb20f97faea820f97faea85b1cee2ef95b1cee2ef907bedab3fe07bedab3fe6de7f6b9506de7f6b9506b46aca8ac6b46aca8ac59ff4f191459ff4f19148a2f7726628a2f772662e460b8f8a2e460b8f8a267e022e36a67e022e36a96a05fecbb@review
Recommendation: Approve. The mocked tests show the intended sampling change, but the fix has not yet been exercised with a real Linux systemd scope. The requested Linux checks and CI are still outstanding. Nothing blocking is left. Recommend approval; not approved on the forge.
Timed queue jobs now wait to identify their systemd scope before sampling its stalls, and use whole-PC pressure when no scope is available. This corrects the source used for noise judgments at the cost of potentially more NOISY results without a scope.
Checks: Still running: 10 checks.
More: does it help, other systems, switches, what was read
Does it help: Unproven on the affected system: the three mocked cases are reported to fail on the base and pass with the change, but no real Linux systemd run has verified scope discovery.
Other systems: The change affects Linux timed queue jobs and their history and dev.py ab noise judgments. Windows has no PSI sampling and the reported Windows mocked tests pass. Real systemd scope discovery remains to be checked.
Switches: None added, changed or removed. LONGSHOT_QUEUE_SCOPE remains enabled by default; disabling it now selects whole-PC pressure as described.
Reviewed:
96a05fecbbagainst9a23e32ef4: Read the diff and commits, AGENTS.md, CONTRIBUTING.md, the PR template, standards, the changed queue logic and new tests, and the noise-summary consumer. Skimmed the remainder of the queue tests and developing guide. docs/review-checklist.md and the adjacent Tooling checkout were absent.; nothing run (a code review).Checked and fine:
Testing: No commands from the project or tests were run during review. The author reports Windows mocked-test results; the Linux systemd checks and CI are pending.
Overlaps and merge order: The description identifies #2610 as fixing two existing Windows queue-suite failures; no merge dependency for this change is established.
Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.