Repository navigation
obs-gpu-status: Keep one PDH query open between label ticks - #1271
Merged
Merged
Conversation
vpacher
force-pushed
the
perf/1022-pdh-open-query
branch
from
October 17, 2026 17:07
8602645 to
5d9f703
Compare
Member
|
@vpacher Fast Gate fails on clippy |
Contributor
Author
|
@zackees Fixed in 21a73be: a |
This was referenced Oct 17, 2026
…rust#1022) PdhTicker keeps one GPU Engine query open and uses the previous tick as the baseline: the first tick after the query opens only primes it, a failed query or open is retried on the next tick. Tier 1 tests drive it with fake queries. With a stub that never opens a query, 3 of 4 fail: the first-tick baseline, the reopen of a failed query and the retry of a failed open. Only the render-adapter filter passes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s-rust#1022) PdhTicker opens the query once and returns the utilization since the previous call; a failed query or open is retried on the next call. On Windows, EngineQuery opens \GPU Engine(*)\Utilization Percentage and adds the counter once, then does one PdhCollectQueryData per tick; the first tick primes it. PdhSource keeps one ticker, so a label tick no longer opens a query, adds the counter or sleeps 100 ms, and the value is averaged over the second since the previous tick instead of 100 ms. gpu_engine_samples() stays a one-shot read for the probe. The probe takes three label samples one second apart, as the frontend does. 133/133 crate tests pass; clippy -D warnings is clean for macOS and x86_64-pc-windows-msvc. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
clippy::type_complexity rejected the nested Vec<Option<Vec<...>>> of the ticker helper; a Collections alias names one fake query's results. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
zackees
force-pushed
the
perf/1022-pdh-open-query
branch
from
October 17, 2026 17:41
21a73be to
8b15895
Compare
Member
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
What and why
The follow-up from the review of #1264:
gpu_engine_samples()opened a PDH query, added the counter, collected twice 100 ms apart and closed the query, on every label tick. On an RTX 3060 that cost about 230 ms per tick (900 ms for the first), and the value covered only 100 ms of the second.This PR keeps one query open:
pdh::PdhTicker(Tier 1, platform-neutral) keeps oneEngineCountersquery and returns the utilization since the previous call. The first call after the query opens only primes it (Unavailable). A failed query, or a failed open, is retried on the next call.platform/windows.rs:EngineQueryopens\GPU Engine(*)\Utilization Percentageand adds the counter once; each tick is onePdhCollectQueryDataand the read of the array (the read code is unchanged, nowread_counter()). No 100 ms sleep: the previous tick is the baseline, so the value is the average over the second since then.PdhSourcekeeps one ticker.gpu_engine_samples()stays as a one-shot read (open, prime, 100 ms, read) for the probe.RED → GREEN
Rebased onto master after obs-gpu-status: Windows GPU: x% from PDH GPU Engine counters #1264 merged (by zackees; the patch is unchanged).
RED af4f8f3: four Tier 1 tests drive
PdhTickerwith fake queries. With a stub that never opens a query, 3 fail: the first-tick baseline (left: Unavailable, right: Percent(37)), the reopen of a failed query (Percent(25)) and the retry of a failed open (Percent(9)). The render-adapter filter passes with the stub.GREEN f9f801b: 133/133 crate tests pass on macOS. 8b15895 names the fake query results in the tests (clippy
type_complexity, which Fast Gate caught: my local clippy output went through a filter that missed soldr's timestamp prefix). Now clippy-D warningsfinishes clean foraarch64-apple-darwinandx86_64-pc-windows-msvc, checked on theFinishedline. fmt is clean.Real hardware: the same Windows 11 VM with the RTX 3060 (driver 617.42) as obs-gpu-status: Windows GPU: x% from PDH GPU Engine counters #1264, the old probe (a new query per sample) and the new one (three ticks per run), idle and under a GPU-bound WebGL load:
nvidia-smi30 %, then 39 %)A tick is about 500 times cheaper, and the one-second average follows
nvidia-smimore closely than the 100 ms window did.Real app: not applicable (no change in what the label shows, only how often the source costs time). The Windows app check for frontend: GPU: x% readout replaces the GPU status light #1025 waits for a beta that has obs-gpu-status: Windows GPU: x% from PDH GPU Engine counters #1264.
Checklist
master(or the description starts with a Stacked: note)docs/features.mdis added or updated (not applicable: no user-visible change)-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