Skip to content

CpuCoreFix#171

Merged
ecbadeaux merged 1 commit intomainfrom
UtilizationFix
Mar 4, 2026
Merged

CpuCoreFix#171
ecbadeaux merged 1 commit intomainfrom
UtilizationFix

Conversation

@ecbadeaux
Copy link
Contributor

@ecbadeaux ecbadeaux commented Mar 3, 2026

Summary
Fixes sys.cpu.coreUtilization reporting values above 100%, caused by two bugs in ComputeGaugeValues related to how /proc/stat fields were interpreted.

Bug 1: iowait non-monotonicity causing values far above 100%

The iowait field in /proc/stat is documented as non-monotonic on SMP systems — it can decrease between readings. delta_wait was already clamped to 0 when iowait decreased, but delta_total was computed from current.total - prev.total, so the decrease still shrank the denominator. When iowait dropped significantly while other usage stayed constant, delta_total would collapse to near zero while numerators remained large, producing percentages like 5000%.

The fix computes delta_total from the same clamped individual deltas rather than the raw totals, so an iowait decrease no longer affects the denominator.

Bug 2: guest time double-counted

Per /proc/stat semantics, guest and guest_nice time is already included within user and nice respectively. The previous code added guest a second time in both the delta_total denominator (via the total field) and in the usage sum in UpdateCoreUtilization. Because the double-counting occurred in both the numerator and denominator, it did not cause values above 100% — but it did cause percentages to be slightly underreported on systems running VMs. Both have been corrected, and the now-unused Cpu_Gauge_Values::guest field and CpuStatFields::total field have been removed.

@ecbadeaux ecbadeaux merged commit bb2750a into main Mar 4, 2026
2 checks passed
@ecbadeaux ecbadeaux deleted the UtilizationFix branch March 4, 2026 05:35
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