Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Total CPU usage is 1% off #970

Open
RealFX-Code opened this issue Nov 13, 2024 · 2 comments · May be fixed by #1008
Open

[BUG] Total CPU usage is 1% off #970

RealFX-Code opened this issue Nov 13, 2024 · 2 comments · May be fixed by #1008
Assignees
Labels
bug Something isn't working

Comments

@RealFX-Code
Copy link

Describe the bug

When running an all core load (compiling applications) All of my cores show 100% usage, while the total CPU usage% bar shows 99%.

To Reproduce

Compile something, in my case I'm compiling net-im/telegram-desktop on gentoo.

Expected behavior

The CPU Usage% bar to show 100% when all of my cores show 100%.

Screenshots

20241113_08h43m27s_grim

Info (please complete the following information):

  • btop++ version: 1.3.2-1
  • Binary: Gentoo binary release
  • Architecture: x86_64
  • Platform: Linux
  • (Linux) Kernel: 6.11.5-xanmod1
  • Terminal used: Alacritty
  • Font used: JetBrainsMono Nerd Font

Additional context

2024/11/13 (08:36:46) | ===> btop++ v.1.3.2
2024/11/13 (08:36:46) | INFO: Logger set to INFO
2024/11/13 (08:36:47) | INFO: Logger set to DEBUG
2024/11/13 (08:36:48) | INFO: Logger set to INFO
@RealFX-Code RealFX-Code added the bug Something isn't working label Nov 13, 2024
@RealFX-Code
Copy link
Author

I updated to 1.4.0 and it didn't make a difference.

@TerenceTux
Copy link

This seems to be caused by these two lines, which sets the amount of idle (and total) cpu ticks to at least 1:

const long long calc_totals = max(1ll, totals - cpu_old.at("totals"));
const long long calc_idles = max(1ll, idles - cpu_old.at("idles"));

So, even when your cpu's are fully used, calc_idles will be 1 instead of 0.
This isn't noticeable with high interval times, but with low interval times the total percentage will be slightly too low.

When the idle ticks per cpu are calculated, 0 is used, therefore the percentage per cpu is correct:

const long long calc_totals = max(0ll, totals - core_old_totals.at(i-1));
const long long calc_idles = max(0ll, idles - core_old_idles.at(i-1));

I think we can just do this too for the total calculation. But when calc_totals is 0, a division by zero would occur, so there has to be made an exception for that.

@TerenceTux TerenceTux linked a pull request Jan 8, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants