Skip to content

Comments

fix: normalize CPU % against container cpuLimit and add soft ceiling to BarChart#4464

Open
amir20 wants to merge 2 commits intomasterfrom
fix/cpu-normalization-soft-ceiling
Open

fix: normalize CPU % against container cpuLimit and add soft ceiling to BarChart#4464
amir20 wants to merge 2 commits intomasterfrom
fix/cpu-normalization-soft-ceiling

Conversation

@amir20
Copy link
Owner

@amir20 amir20 commented Feb 20, 2026

Summary

  • CPU normalization fix: When a container has a CPU limit (--cpus=N), the frontend was dividing raw CPU% by 1 instead of N. A --cpus=2 container using 1.5 cores now correctly shows 75% instead of being capped at 100%. Fixed in ContainerStatCell, HostCard, and MultiContainerStat.
  • BarChart soft ceiling: Added maxCeiling prop (default 10) so bar scaling uses max(dataMax * 1.2, maxCeiling) instead of just max(data). Idle containers stay visually flat instead of filling the full chart height. Spikes are visible relative to recent history.

Test plan

  • Run 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%)
  • Run a container with no CPU limit and verify it still normalizes against host CPU count
  • Verify idle containers show small bars in the container table, not full-height
  • Verify a CPU spike shows meaningful visual variation in the bar chart
  • Run pnpm test and pnpm typecheck — both pass

🤖 Generated with Claude Code

…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>
@claude
Copy link

claude bot commented Feb 20, 2026

Review

CPU 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:

  • MetricCard in HostCard.vue passes totalCPU which is a sum across all containers (can exceed 100%). Old code capped at 100% height; new code scales relatively — actually better, but data passed as percent to MetricDataPoint semantically implies 0-100 and could exceed that on multi-container hosts. Not a blocker.
  • StatMonitor.vue passes raw y-values (not percentages). Old Math.min(dataPoint, 100)% would incorrectly cap non-percentage data. New relative scaling is strictly better here.
  • The maxCeiling = 10 creates a visual discontinuity around 8.3% (where dataMax * 1.2 overtakes the ceiling). Containers hovering near that threshold will see the scale shift. Minor visual edge case.

No bugs, no security concerns. The CPU normalization is the substantive fix here.

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