Repository navigation
obs-gpu-status: Windows GPU utilization through PDH GPU Engine counters - #1228
Merged
Merged
Conversation
zackees
force-pushed
the
feat/1022-pdh-gpu-engine
branch
from
October 17, 2026 11:42
bd46ede to
fad2dec
Compare
zackees
enabled auto-merge
October 17, 2026 11:42
3 of 6 tasks
3 of 6 tasks
zackees
added a commit
that referenced
this pull request
Oct 17, 2026
#1228 reads the Windows GPU engine counters through PDH; the crate's #[link(name = "pdh")] doesn't reach the final link of a Rust staticlib, so obs64.exe failed with LNK2019 on PdhOpenQueryW and four more (master full run 39033323680). The frontend links pdh on Windows next to the staticlib.
This was referenced Oct 17, 2026
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
Design
src/pdh.rs(platform-neutral):PdhInstanceandparse_pdh_instanceforpid_<n>_luid_0x<hi>_0x<lo>_phys_<n>_eng_<n>_engtype_<type>(hex case-insensitive; engtype is everything afterengtype_, e.g.Compute_0).pdh_utilization(samples, luid, pid)keeps the render adapter's LUID (from obs-gpu-status: Pick the Windows render GPU by LUID #1198), and onlypidwhen given. It sums each engine(phys, eng)over processes and takes the busiest engine, which is Task Manager's whole-adapter value. It clamps to 0..=100 and rounds; with no match it returnsUnavailable.src/platform/windows.rs:gpu_engine_samples()uses raw FFI topdh.dll:PdhOpenQueryW,PdhAddEnglishCounterW(\GPU Engine(*)\Utilization Percentage), twoPdhCollectQueryDatacalls 100 ms apart, thenPdhGetFormattedCounterArrayW(PDH_FMT_DOUBLE|PDH_FMT_NOCAP100). That call is sized throughPDH_MORE_DATAand retried when instances churn. Each unsafe block has a SAFETY comment. The query is closed by a Drop guard. It is exposed throughplatform/mod.rs'scfg_select!; other OSes return an empty Vec.RED: 158e288
Tier 1 tests in
tests/gpu_status/pdh.rsuse captured-style instance lists: several engines, two adapters, several processes, a per-pid share, garbage names, a >100 clamp and rounding. Against the stubs, 8 failed and 2 passed (rejects_garbageandunavailable_without_match, because the stubs already return None/Unavailable).GREEN: fad2dec
soldr cargo test -p obs-gpu-status: 97 passed (rebased onto #1224), 0 failed../lintpasses.Cross-compile
uv run ci/local_gate.py --lane crosspasses. It runs clippy and dylint and links every test binary for x86_64-pc-windows-msvc (includinggpu_status.exe) and for macOS.Not verified
gpu_engine_samples()yet.All of these need a Windows host, so this PR uses Refs, not Fixes.