fix: normalize CPU % against container cpuLimit and add soft ceiling to BarChart#4464
Open
fix: normalize CPU % against container cpuLimit and add soft ceiling to BarChart#4464
Conversation
…to BarChart CPU normalization was dividing by 1 when a container had a CPU limit set, instead of dividing by the actual limit. A --cpus=2 container at 150% now correctly shows 75% instead of being capped at 100%. BarChart now uses a soft ceiling (max(dataMax * 1.2, 10)) so idle containers stay visually flat instead of filling the full chart height. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
ReviewCPU normalization fix - Correct. calculateCPUPercentUnix multiplies by onlineCPUs, so a container with --cpus=2 at full utilization reports 200% raw. The old return 1 divided by 1, overcapping at 100%. Dividing by cpuLimit (2.0) gives correct 100%. Fix is consistent across all three files. BarChart soft ceiling - Improvement for relative scaling, but one behavioral note:
No bugs, no security concerns. The CPU normalization is the substantive fix here. |
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
--cpus=N), the frontend was dividing raw CPU% by1instead ofN. A--cpus=2container using 1.5 cores now correctly shows 75% instead of being capped at 100%. Fixed inContainerStatCell,HostCard, andMultiContainerStat.maxCeilingprop (default10) so bar scaling usesmax(dataMax * 1.2, maxCeiling)instead of justmax(data). Idle containers stay visually flat instead of filling the full chart height. Spikes are visible relative to recent history.Test plan
docker run -d --cpus=2 alpine sh -c "for i in 1 2 3 4; do while true; do :; done & done; wait"and verify Dozzle shows ~100% (not capped at 100% from raw 200%)pnpm testandpnpm typecheck— both pass🤖 Generated with Claude Code