feat(gpu): support Apple Silicon GPU usage and unified memory#12
Conversation
sysmon previously only knew how to read GPU stats from nvidia-smi and rocm-smi. On Apple Silicon Macs neither tool exists, so GPU usage always showed 0%, and the separate "Memory" and "GPU Memory" bars were misleading since the CPU and GPU share one unified memory pool. - Detect Apple Silicon's integrated GPU and read "Device Utilization %" from `ioreg -c IOAccelerator` (no extra tools or sudo required) - Add a UnifiedMemory flag and render a single full-width "Unified Memory" bar instead of the redundant Memory / GPU Memory split - Add tests for the ioreg parser and the unified-memory view - Update README Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: PinePeakDigital/coderabbit/.coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis PR adds Apple Silicon GPU support to a system monitoring application. It introduces a ChangesApple Silicon GPU Support
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Pull request overview
Adds macOS Apple Silicon GPU utilization support and updates the TUI to properly represent unified-memory systems, avoiding misleading “GPU Memory” reporting when CPU/GPU share a single pool.
Changes:
- Detect Apple GPU on macOS and read GPU usage via
ioreg(Device Utilization %) with a new parser. - Add
SystemStats.UnifiedMemoryand render a single full-width “Unified Memory” bar when enabled. - Add unit tests for the
ioregparser and unified-memory view; update README with platform/tooling notes.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| README.md | Documents Apple Silicon GPU stats via ioreg and the unified-memory UI behavior. |
| main.go | Implements Apple GPU vendor detection/usage parsing and unified-memory-aware rendering. |
| main_test.go | Adds tests for parseAppleGPUUsage and unified-memory view output behavior. |
Intel Macs also expose IOAccelerator stats via ioreg but have discrete/non-unified memory. Without an arch gate they would incorrectly use the Apple GPU parser and unified-memory layout. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Auto-applied low-risk findings: - Align the unified-memory bar to barWidth*2+spacing so its right edge matches the CPU/GPU row above it (was using raw m.width, 1 char wider on odd-width terminals). - Accept a decimal point in the Device Utilization parser so a fractional reading isn't silently truncated; add a test case. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Problem
On Apple Silicon Macs, sysmon's GPU usage always showed 0%, and it displayed separate Memory and GPU Memory bars even though the CPU and GPU share a single unified memory pool.
The root cause:
detectGPUVendoronly knew how to read stats fromnvidia-smi(NVIDIA) androcm-smi(AMD). Neither exists on macOS, so detection fell through togpuVendorNone→ constant 0%. There was also no concept of unified memory, so the redundant two-bar memory layout was always used.Fix
gpuVendorApplevendor, detected on macOS by readingioreg -r -d 1 -w 0 -c IOAccelerator. GPU usage comes from theDevice Utilization %field (the same figure Activity Monitor reports) — no extra tools and nosudorequired.UnifiedMemoryflag toSystemStats. When set, the view renders a single full-width "Unified Memory" bar instead of the misleading Memory / GPU Memory split.ioregparser (parseAppleGPUUsage) and the unified-memory view.Testing
go vet,go test, andgo buildall pass.🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Documentation
Tests