Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.