Host CPU Core Utilization, Frequency & Throttle Monitoring #5
Notifications
Due Date
No due date set.
Depends on
Reference: gronod/MacMonitor#5
Reference in New Issue
Block a user
Purpose
Deliver real-time telemetry on overall system CPU usage and individual per-core processor load (User, System, Nice, Idle), alongside clock frequency and CPU throttling indicators on Intel x86_64 architectures.
Priority
Critical (Fundamental system health and workload indicator)
Dependencies
Scope
host_processor_infowithPROCESSOR_CPU_LOAD_INFO.hw.cpufrequencyor SMC frequency keys).Implementation Suggestions
host_processor_info(mach_host_self(), PROCESSOR_CPU_LOAD_INFO, ...)in Objective-C, calculating delta ticks between consecutive sampling intervals:delta_user = current.user - previous.user, etc.machdep.cpu.brand_string,hw.physicalcpu,hw.logicalcpu, andhw.cpufrequency.[Double]to SwiftUI for rendering dynamic core grid visualizations.Technical Implementation Plan & Code Solution
1. Mach Host Processor Load Architecture
MacOS Mach kernel exposes fine-grained tick counters for every logical processor core via
host_processor_infowithPROCESSOR_CPU_LOAD_INFO.Tick categories tracked per core:
CPU_STATE_USERCPU_STATE_SYSTEMCPU_STATE_IDLECPU_STATE_NICE2. Objective-C Provider (
MMCPUUsageProvider.m)3. Swift UI Integration
4. Critical Memory Management Detail
Every call to
host_processor_info()allocates a kernel Mach virtual memory buffercpuInfo. It is mandatory to invokevm_deallocate()on each previous pointer to prevent virtual memory leak accumulation over long runtimes.Completed in
feat/5-cpu-loadand merged intodevelop.MMCPULoadProviderquerying Mach kernelhost_processor_info(PROCESSOR_CPU_LOAD_INFO).hw.cpufrequency_max) and thermal throttling detection.MMCPULoadTests.swift.