system, check: warn when a benchmark ran under a cgroup CPU quota #277
All Vouch review confidence checks passed
Residual risk 0.05 = Change Risk (0.45) × (1 − Review Confidence (0.89)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.45 · 245 lines diff across 7 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.89 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.329
Real PR Conversation Timeline
2 items
Please don't duplicate code, there is already get_cgroup_cpu_quota(). Why not reusing it?
vstinner
manunicholasjacob
Problem
pyperf system showruns ten operations andpyperf checkwarns on four statistical conditions, but nothing in either looks at whether the benchmark was throttled while it ran.A cgroup CPU quota (
docker run --cpus, a Kubernetes CPU limit, systemdCPUQuota=) throttles the benchmark, and throttling does not look like noise. A quota that binds for the whole run slows every value by about the same factor, so the mean shifts but the relative spread does not, and the result comes back looking statistically stable while being wrong. The advicecheckoffers on an unstable result (more runs and values,pyperf system tune) does not help, because the machine was not jittery, it was capped. This is the common case on CI runners and in containers. Follows up #274 and reuses thecpu_quotadetection from #265.What this does
system show: a new "CPU quota" operation, next to "Power supply", that reports a binding quota (viaget_cgroup_cpu_quota()) and, from cgroup v2cpu.stat, whether the benchmark cgroup was throttled. It reports and advises only, the same shape as the power supply check, because nothing pyperf can tune fixes an externally imposed quota.check: warns when a saved result carriescpu_quotametadata, so a stored result is judged after the fact instead of reading as stable._collect_metadata.py: addsget_cgroup_cpu_throttling()besideget_cgroup_cpu_quota(). It walks the same cgroup hierarchy and readsnr_throttled/throttled_usec(cgroup v2) orthrottled_time(cgroup v1), taking the largest counters across the hierarchy because the throttling is recorded where the limit binds while the root stays at zero. It returnsNonewhen the counters cannot be read, so "could not be checked" stays distinct from zero.Scope
This is the quota-detection piece. The two design questions in #274 are left as follow-ups: capturing the per-run
cpu.statdelta around the benchmark (and whether to store throttle counters in metadata), and thermal throttling (core_throttle_counton x86,vcgencmd get_throttledon the Pi), where "could not be checked" has to stay distinct from zero.Tests
test_metadata.py: cgroup v2 throttled, zero-is-not-None, cgroup v1 nanosecond conversion, and no-cgroup returningNone.test_cli.py:checkwarns oncpu_quotametadata and does not warn without it.test_system.py: the CPU quota operation is silent with no quota, reports a set quota, and reports throttling.Checked on a Raspberry Pi 5
Under
systemd-run --user --scope -p CPUQuota=25%, released pyperf reports "The benchmark seems to be stable" on a run that was throttled for hundreds of milliseconds, andsystem showsays nothing about the quota. With this changecheckwarns that the benchmark ran under a CPU quota, andsystem showreports the quota and the throttling.