Skip to content

Add macos_thermal_pressure and macos_soc_power tables#83

Merged
grahamgilbert merged 3 commits intomainfrom
gg/thermal-power-tables
Mar 16, 2026
Merged

Add macos_thermal_pressure and macos_soc_power tables#83
grahamgilbert merged 3 commits intomainfrom
gg/thermal-power-tables

Conversation

@grahamgilbert
Copy link
Contributor

Summary

  • Adds macos_thermal_pressure table: exposes Apple's OS-level thermal throttling state (Nominal/Light/Moderate/Heavy/Sleeping) and a derived is_throttling integer via powermetrics --samplers thermal
  • Adds macos_soc_power table: exposes CPU, GPU, ANE (Apple Neural Engine), and combined SoC power draw in mW plus GPU active ratio via powermetrics --samplers cpu_power,gpu_power,ane_power
  • Both tables are macOS-only, require root, and accept a constrainable interval column (defaults: 1000ms and 3000ms respectively)
  • Fixes energy_impact README note to use 1000 instead of 1000ms for the interval default

Test plan

  • go test ./tables/thermalthrottling/... ./tables/socpower/... passes
  • Query select * from macos_thermal_pressure; returns a row with thermal_pressure = Nominal on an idle device
  • Query select * from macos_soc_power; returns a row with plausible mW values
  • Query select * from macos_thermal_pressure where interval = 500; uses the custom interval

🤖 Generated with Claude Code

grahamgilbert and others added 3 commits March 16, 2026 11:25
Adds two new macOS-only tables powered by powermetrics:

- `macos_thermal_pressure`: exposes the OS thermal pressure state
  (Nominal/Light/Moderate/Heavy/Sleeping) and a derived `is_throttling`
  integer, using the `thermal` sampler with a 1000ms default interval.

- `macos_soc_power`: exposes CPU, GPU, ANE, and combined SoC power draw
  in mW plus GPU active ratio, using the `cpu_power,gpu_power,ane_power`
  samplers with a 3000ms default interval for meaningful averages.

Both tables accept a constrainable `interval` column.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add TestThermalPressureGenerate and TestRunPowermetricsStatError to cover
the Generate function and the non-ErrNotExist stat error path, bringing
coverage from 38.7% to 67.7%.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@grahamgilbert grahamgilbert merged commit de17362 into main Mar 16, 2026
10 checks passed
@grahamgilbert grahamgilbert deleted the gg/thermal-power-tables branch March 16, 2026 20:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants