Repository navigation
obs-gpu-status: Back off from slow GPU usage sources - #1287
Merged
Merged
Conversation
…1022) Tier 1 tests with a fake clock that fake sources advance by their cost: the pause after a sample grows with its duration (9 times, 1 s to 30 s) and recovers; a reading older than 3 intervals is not shown, and the tooltip says it is late; a source slow (over 2 s) 3 times in a row is demoted once, with its call times, and the next source answers. With stubs that keep 1 s, never age a reading and never demote, 6 fail (5 backoff tests and the en-US readout keys); a fast sample resetting the count passes with the stubs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…t#1022) next_interval pauses 9 times the sample's duration, 1 s to 30 s, so a slow source takes at most about a tenth of the obs-gpu-usage thread's time and a fast sample gives 1 s again. current drops a reading older than 3 pauses, also while a sample hangs: the label shows "GPU: n/a" and the tooltip "The GPU reading is late." (new en-US key). The Sampler times each source call; a source over 2 s three times in a row is not asked again, and the next source answers. The thread publishes each sample with its time and pause; the report checks its age. A demotion becomes one OBS log line ("GPU usage: <source> is too slow (<times>); not asked again in this session") that the frontend takes with the new obs_gpu_status_take_log() in Query() and logs once. 136/136 crate tests pass; clippy -D warnings finishes clean for macOS and x86_64-pc-windows-msvc; clang-format is clean. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #1022
Go-ahead for this part of #1022 (the claim bot only sees the issue-level claim): #1022 (comment)
What and why
The backoff follow-up from #1022 (zackees' proposal, claimed in #1022 (comment)): a usage source that is slow must not keep the
obs-gpu-usagethread busy, must not leave an old number on the label, and must not be asked forever. It applies to every source (NVML, amdgpu, IOKit, PDH). #1271 makes PDH's normal cost small; this covers the degenerate case.This PR (the defaults from the claim):
usage::next_interval(elapsed)= 9 × the sample's duration, at least 1 s, at most 30 s. Sampling takes at most about a tenth of the thread's time; the next fast sample gives 1 s again.usage::current()drops a reading older than 3 pauses, also while a sample hangs. The label showsGPU: n/aand the tooltip "The GPU reading is late." (new en-US keyBasic.StatusBar.Gpu.Stale, not the "no source" text); the JSONusageisnull.Samplertimes each source call (injectable clock). A call over 2 s is slow; 3 slow calls in a row demote the source for the session, and the next source answers. A fast call resets the count. Each demotion is reported once.GPU usage: pdh is too slow (2500 ms, 3000 ms, 2100 ms); not asked again in this session. The thread queues it; the frontend takes it with the newobs_gpu_status_take_log()inGpuStatus::Query()and logs it withblog(LOG_WARNING). Not in the report JSON, so a GetStats call cannot swallow it.docs/gpu-status.md; the ledger line indocs/features.md.Differences from the claim: the stale tooltip says "The GPU reading is late." instead of reusing the "no source" text, which would be wrong for a source that exists; the pacing is a function (
next_interval), not aPacertype; and the PR does not wait for #1271, because it is independent of it.Independent of #1264 and #1271 (different files, apart from separate paragraphs in the docs); the tests use
Source::Iokitas the slow source, so they do not needSource::Pdh.RED → GREEN
left: 1s, right: 1.8s), staleness (left: Some(..), right: None), demotion (left: [], right: [Demotion { source: Iokit, times: [2.5s, 3s, 2.1s] }]), a slow source without a reading, the stale tooltip (NoSourcevsStale) and the en-US readout keys (4 vs 5). "A fast sample resets the count" passes with the stubs.obs_gpu_status_take_log). clippy-D warningsfinishes clean foraarch64-apple-darwinandx86_64-pc-windows-msvc(checked on theFinishedline). clang-format (ci/local_gate.py --only clang-format, 22.1.3) is clean.33.0.0-beta6-1528-gb88e57200), fresh config: the status bar showsGPU: 99%under a Metal compute load (ioreg: 99), the startup log saysGPU acceleration: green, and noGPU usageline is logged (no source is slow). The slow paths are covered by the Tier 1 tests; no real source on this machine is slow.Checklist
master(or the description starts with a Stacked: note)docs/features.mdis added or updated-W..., ratchets): built with scripting ON (a flag change under cmake/ or build-aux/ runs the full builds) and cross-checked with clang and MSVC (not applicable: no flag changes)🤖 Generated with Claude Code