thermal-governor
thermal-governor demonstrates github.com/tmc/apple/x/thermal with zero cgo (CGO_ENABLED=0):
- Reads live macOS thermal state via Foundation's
NSProcessInfo.thermalState
- Detects active power source and battery percentage via IOKit's
IOPSCopyPowerSourcesInfo
- Samples Apple Silicon SoC power/energy via
x/powersample (unprivileged libIOReport.dylib with graceful degradation if power sampling is unavailable)
- Watches thermal state during a synthetic compute workload, evaluates the benchmark qualification gate (
thermal.DefaultGate()), and reports joules per token
Run
CGO_ENABLED=0 go run ./examples/os/thermal-governor
Flags:
-duration: synthetic workload duration (default 600ms)
-interval: thermal watch and power sample interval (default 150ms)
-tokens: synthetic token count for joules/token calculation (default 512)
Measured Output
Captured on this Mac with CGO_ENABLED=0 go run ./examples/os/thermal-governor:
== Host Status ==
thermal state : fair
power source : ac (100%)
idle power : 12.02 W combined (CPU 11.72 W, GPU 0.30 W, ANE 0.00 W; 3 samples)
== Synthetic Compute Workload (600ms, 512 synthetic tokens) ==
[watch #1] state=fair power=ac (100%)
[watch #2] state=fair power=ac (100%)
[watch #3] state=fair power=ac (100%)
[watch #4] state=fair power=ac (100%)
== Benchmark Qualification & Energy Summary ==
elapsed : 600ms
watch samples : 4
thermal : fair -> fair
power source : ac (100%) -> ac (100%)
gate verdict : FAIL (thermal: state exceeds benchmark gate: before=fair after=fair max=nominal)
energy : 7.547 J combined (CPU 7.395 J, GPU 0.152 J, ANE 0.000 J)
average power : 12.33 W combined (CPU 12.08 W, GPU 0.25 W, ANE 0.00 W; 5 samples)
efficiency : 0.01474 J/token (512 tokens)