Fill the macOS GPU monitoring gap in internal/perf/monitor_darwin.go using ioreg for Apple Silicon
#814
Pauliehedron
started this conversation in
Ideas
Replies: 2 comments 3 replies
-
|
Trying out |
Beta Was this translation helpful? Give feedback.
1 reply
-
|
See PR #816 Using a combo of mactop and ioreg (I got it to work) we can get performance stats for OSX. mactop is easy to install with |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Title
Fill the macOS GPU monitoring gap in
internal/perf/monitor_darwin.gousingioregfor Apple SiliconCategory
Ideas
One-paragraph summary
internal/perf/monitors CPU, memory, swap, and load on all platforms, and GPU on Linux (LACT → nvidia-smi → rocm-smi) and Windows (nvidia-smi). On macOS (monitor_darwin.go), the GPU path isreturn nil, ErrNotImplemented— a hardcoded stub. Apple Silicon Macs are a significant deployment target for llama.cpp and llama-swap (unified memory is well-suited for local models), and the data is available from the IOKit driver viaioreg -c IOGPU -d 1, which returns GPU utilization percentages and memory allocation in a simple text dictionary.Data available from Apple Silicon
GpuUtilPctioreg→PerformanceStatistics→"Device Utilization %"(0-100)MemUsedMB,MemTotalMB"In use system memory"/"Alloc system memory"(bytes, /1M)ID,NameIONameMatchedkey in ioreg output (e.g.,gpu,t6000) orsystem_profiler SPDisplaysDataTypeThree fields Apple Silicon cannot supply remain at Go zero-values (which Prometheus output already handles gracefully by omitting zero metrics):
TempC,FanSpeedPct,PowerDrawW— no public macOS API exposes these. Unified memory meansMemTotalMBis GPU-allocated portion, not discrete VRAM.Shape of the change
One function in one file: replace the stub
getGpuStats()ininternal/perf/monitor_darwin.gowith an implementation that:ioreg -c IOGPU— if it returns data (Apple Silicon), proceed. If empty or not found (Intel Mac, AMD), returnErrNoGpuToolpreserving current behavior.ioreg -r -c IOGPU -d 1at the configured interval viaexec.CommandContext, same exec/pipe/scanner pattern already used fornvidia-smion Linux/Windows.PerformanceStatisticsdictionary — key-value text with quoted keys, unquoted integer values. Trivially parseable with Go'sbufio.Scannerandstringspackage, same pattern asgpu_parse.go.GpuStatsnapshots on the existing channel.No new config keys, no build-tag changes, no new dependencies. The
//go:build darwintag already isolates this file. No platform-version detection needed —ioreg -c IOGPUreturns data on Apple Silicon regardless of macOS version, and returns nothing on Intel.Why it matters
Apple Silicon is the primary hardware for local LLM inference on macOS. Users running llama-swap on their Macs currently get zero GPU visibility in
/metrics— they see CPU per-core, memory, swap, and load averages but a blank GPU section in the web UI. The data is already in the kernel's IOKit tree; the project just needs to ask for it.Implementation flexibility
The parsing is the only variable part. The
PerformanceStatisticsdict is text-based and stable across macOS releases (Apple has not changed these IOKit keys in years). It could be parsed with:bufio.Scanner+strings.Split/Trim— matches existing nvidia-smi pattern"Key" = ValuelinesAll three are zero-dependency. The data rate (one poll per 5s by default) is negligible —
ioregcompletes in ~100ms.Idea drafted with assistance from Ensemble (ENSEMBLE Framework v3.3.3 protocol on Hermes Agent). Accountable human: @Pauliehedron, Conductor
Beta Was this translation helpful? Give feedback.
All reactions