Repository navigation
obs-gpu-status: macOS GPU utilization from IOKit PerformanceStatistics - #1262
Merged
Merged
Conversation
…#1026) Tier 1 tests for iokit::device_utilization on a PerformanceStatistics dictionary captured from an M1 Max (macOS 26.7.1) while the GPU was busy. The stub returns Unavailable: the captured dictionary and the 0 and 100 bounds fail; a missing key and values outside 0 to 100 pass. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…st#1026) iokit::device_utilization takes the PerformanceStatistics number entries and returns Device Utilization % as the whole-GPU percent. Renderer and Tiler Utilization % are parts of the GPU and do not stand in for it. A missing key or a value outside 0 to 100 is Unavailable. 129/129 crate tests pass. Co-Authored-By: Claude Opus 5.5 <[email protected]>
platform::usage_sources() gets an IOKit source on macOS. It reads the PerformanceStatistics dictionary of the IOAccelerator service with the render adapter's registry ID (obs-rust#1195) through IORegistryEntryIDMatching and IORegistryEntryCreateCFProperty, and gives its number entries to iokit::device_utilization. IOKit and CoreFoundation open at run time through libloading, as the rest of the macOS code does. The JSON source name is "iokit". The probe prints the label's sample. On an M1 Max (macOS 26.7.1) the render adapter is 0x100000b5b (AGXAcceleratorG13X); the sample is 13 % idle and 99 % under a Metal compute load, the same as ioreg, in about 0.6 ms. clippy -D warnings is clean for macOS and Windows. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The status bar of this branch's app on an M1 Max under a Metal compute load: GPU: 99% with a green dot (ioreg: Device Utilization % 98). Co-Authored-By: Claude Opus 5.5 <[email protected]>
vpacher
marked this pull request as ready for review
October 17, 2026 16:14
vpacher
marked this pull request as draft
October 17, 2026 16:14
zackees
approved these changes
Oct 17, 2026
vpacher
marked this pull request as ready for review
October 17, 2026 16:31
3 of 6 tasks
vpacher
added a commit
to vpacher/obs-studio
that referenced
this pull request
Oct 17, 2026
The features ledger line for the GPU: x% label names all three platforms and their sources: NVML and gpu_busy_percent on Linux, IOKit on macOS (obs-rust#1262, merged before the ledger existed) and PDH on Windows. Co-Authored-By: Claude Opus 5.5 <[email protected]>
vpacher
added a commit
to vpacher/obs-studio
that referenced
this pull request
Oct 17, 2026
The features ledger line for the GPU: x% label names all three platforms and their sources: NVML and gpu_busy_percent on Linux, IOKit on macOS (obs-rust#1262, merged before the ledger existed) and PDH on Windows. Co-Authored-By: Claude Opus 5.5 <[email protected]>
chriscoveries
pushed a commit
to chriscoveries/obsrust-fork
that referenced
this pull request
Oct 17, 2026
…t#1264) * obs-gpu-status: Windows GPU: x% from PDH (RED, Refs obs-rust#1025) Source::Pdh names the Windows PDH GPU Engine counters (obs-rust#1022) in the JSON; the stub name is empty, so source_names fails. A Windows-only test requires usage_sources() to ask NVML, then PDH; it fails on Windows, where PDH is not wired in yet. Co-Authored-By: Claude Opus 5.5 <[email protected]> * obs-gpu-status: Windows GPU: x% from PDH (GREEN, Refs obs-rust#1025) platform::usage_sources() asks the PDH GPU Engine counters (obs-rust#1022, LUID (obs-rust#1198) through pdh_utilization, the busiest engine as Task Manager shows it, for every vendor. NVML cannot map the LUID to a PCI address yet, so PDH also reads NVIDIA GPUs on Windows. One sample blocks for 100 ms on the obs-gpu-usage thread, never the UI thread. The JSON source name is "pdh". 125/125 crate tests pass on macOS; clippy -D warnings is clean for macOS and x86_64-pc-windows-msvc. Co-Authored-By: Claude Opus 5.5 <[email protected]> * docs: GPU: x% ledger line covers macOS and Windows (Refs obs-rust#1025) The features ledger line for the GPU: x% label names all three platforms and their sources: NVML and gpu_busy_percent on Linux, IOKit on macOS (obs-rust#1262, merged before the ledger existed) and PDH on Windows. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
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.
Fixes #1026
Refs #1025
What and why
On macOS the
GPU: x%label (#1025, #1236) showsGPU: n/a, because no source reads the render GPU. This PR adds one: IOKit'sPerformanceStatisticsdictionary of the render GPU'sIOAcceleratorservice, keyDevice Utilization %.The issue says that the key is unverified on Apple Silicon. On an M1 Max (macOS 26.7.1),
AGXAcceleratorG13Xhas it, together withRenderer Utilization %andTiler Utilization %. The headline isDevice Utilization %, the whole GPU. Renderer and Tiler are parts of it and do not stand in for it.This PR:
iokit::device_utilization(stats)(Tier 1). It takes the dictionary's number entries. A missing key or a value outside 0 to 100 givesUnavailable.accelerator_statistics(registry_id)insrc/platform/macos.rs. It finds the service withIORegistryEntryIDMatching(the registry ID from obs-gpu-status: Pick the macOS render GPU by registry ID #1195), copies the dictionary withIORegistryEntryCreateCFProperty, and returns its number entries. IOKit and CoreFoundation open at run time through libloading, as the rest of the macOS code does, so the crate links no framework.IokitSourcetoplatform::usage_sources()on macOS, after NVML. Its JSON source name isiokit(usage.sourceinGetStats.gpuAcceleration).docs/gpu-status.md(the source and a macOS screenshot).Not in this PR: Windows. The PDH sampler from #1228 is not wired into
usage_sources()yet (#1022, #1025).RED → GREEN
PerformanceStatisticsdictionary captured from the M1 Max while the GPU was busy. With a stub that returnsUnavailable, 2 fail: the captured dictionary (expected 25 %) and the 0 and 100 bounds. A missing key and values outside 0 to 100 pass with the stub.-D warningsis clean foraarch64-apple-darwinandx86_64-pc-windows-msvc. Linux cannot be cross-built from macOS (soldr#2874); PR CI builds it. fmt is clean.RegistryId(0x100000b5b), the ID thatioregshows forAGXAcceleratorG13X. The label sample isSome(UsageSample { percent: 13, source: Iokit })with the Mac in normal use, andpercent: 99under a Metal compute load.ioregshows"Device Utilization %"=99at the same time. One sample takes about 0.6 ms (research: GPU utilization readout in the status bar, merged with the acceleration light #1004 asked for the polling cost per source).cmake --preset macos,ENABLE_BROWSER=OFF) on the same M1 Max. PR CI skips the macOS app build for this Rust-only change, so it was built locally. The status bar showedGPU: 0%with a green dot (version33.0.0-beta6-1520-g2689b3356), thenGPU: 99%under a Metal compute load (ioreg:Device Utilization %98). The startup log is unchanged. f932102 adds that status bar todocs/gpu-status.md:Checklist
master(or the description starts with a Stacked: note)-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