Skip to content

Add Thermal: flag executions run on a hot or throttled CPU - #3

Open
MatejKocourek wants to merge 3 commits into
PRL-PRG:mainfrom
MatejKocourek:thermal-monitoring
Open

MatejKocourek wants to merge 3 commits into
PRL-PRG:mainfrom
MatejKocourek:thermal-monitoring

Conversation

@MatejKocourek

@MatejKocourek MatejKocourek commented Nov 19, 2026 •

Copy link
Copy Markdown

A hot or throttled CPU runs slower, so the numbers measured on it are suspect. This adds Thermal, which records CPU temperature and thermal throttling around every execution and marks the executions where the CPU was at risk.

t = Thermal()
bench("x").with_hook(t).with_metric(t)

What it does

  • Thermal is both a Hook and a Metric (no changes to the controller, builder or report format). Around each execution it samples the CPU temperature (every interval s, default 1) and reads the kernel's throttle counters, then emits two process samples:
    • cpu_temp_max (C): the hottest reading during the execution;
    • cpu_throttle: thermal-throttle events counted during it (summed over CPUs).
  • Both carry extra={"suspect": True} when the CPU throttled or came within margin degrees (default 10) of a limit the hardware declares: hwmon's crit, or a thermal zone's lowest passive/hot/critical trip point. Without a declared limit nothing is flagged as hot.
  • Sensors (Linux): CPU-package hwmon sensors (coretemp, k10temp) and, where no such driver exists (e.g. ARM), thermal zones whose type names the CPU (cpu, pkg, soc). Thermal zones are skipped where hwmon covers the CPU: on x86 laptops they include firmware policy zones (e.g. CPUV with a 60 °C passive trip) whose trips are not CPU limits. Throttle counters come from /sys/devices/system/cpu/cpu*/thermal_throttle/ (where the platform has them).
  • Where the sensors are missing (other OSes, VMs, other hardware) it emits nothing and starts no thread; every read is guarded, so a broken sensor never fails a benchmark.
  • The values show in the summary like any other metric (mean, min … max) and in the JSON/CSV reports per execution.

Tests

tests/test_thermal.py builds fake sysfs trees: Intel hwmon with crit, an ARM-style thermal zone with trip points (ignoring active trips and non-CPU zones), a firmware zone ignored next to coretemp, AMD k10temp without a declared limit, throttling, no sensors, malformed and unreadable sensor files, and a run through Controller with the object as hook and metric. ruff, pyright and the full test suite pass.

Tried on two Intel laptops: three 2 s CPU burns read 77–87 °C, not flagged; on an i5-1335U only coretemp (crit 100 °C) is used, not the firmware's CPUV/TCPU zones.

🤖 Generated with Claude Code

MatejKocourek and others added 3 commits November 19, 2026 20:57
A hot or throttled CPU runs slower, so the numbers measured on it are
suspect. Thermal is both a Hook and a Metric: around every execution it
samples the CPU package temperature (Linux hwmon: coretemp, k10temp) and
reads the kernel's thermal-throttle counters, then emits cpu_temp_max and
cpu_throttle as process samples. Both carry extra={"suspect": True} when
the CPU throttled or came within `margin` degrees of its crit temperature.
Without the sensors it emits nothing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Read CPU thermal zones as well as hwmon, and take each sensor's limit from
the hardware (hwmon crit, the zone's lowest passive/hot/critical trip point)
instead of a fixed fallback: without a declared limit nothing is flagged
as hot. Guard every read and the hook so that missing or broken sensors
only mean no samples.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On x86 laptops firmware zones such as CPUV match the CPU zone names and
declare policy trip points (a 60 C passive one), which flagged nearly every
execution.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

1 participant