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

Inconsistent CPU when compared to htop #17

Open
xxxserxxx opened this issue Feb 15, 2020 · 10 comments
Open

Inconsistent CPU when compared to htop #17

xxxserxxx opened this issue Feb 15, 2020 · 10 comments
Labels
bug Something isn't working needs:review To determine inclusion or wont-fix
Milestone

Comments

@xxxserxxx
Copy link
Owner

Required information:

I've seen inconsistent CPU usage from gotop and htop. For the gotop process, CPU usage ranges from 7 to 15% continuously on htop, but gotop reports around 3%, continuously.

I would guess this is because htop shows the total CPU usage in all CPUs and gotop is showing the CPU usage divided by the number of cores. Is this correct? Is this the intended behavior? Or should it follow htop style and go to 400% in a 4 core CPU?

screenshot 2019-02-05 15 11 24

@xxxserxxx
Copy link
Owner Author

Yah, gotop divides the CPU usage by the number of cores to show overall CPU usage which differs from the way htop/top works. I hadn't noticed that descrepency before so thanks for pointing that out. Is one way better than the other? If people want per-core CPU usage then maybe we could add a cli option to allow choosing between the two.

@xxxserxxx
Copy link
Owner Author

afaik, it's common that cores go to 100%, CPU goes to 100%*nr of cores. So a process using 150% CPU in a quad-core will, in fact, be using one core at 100% and another at 50% - or any other combination of it.

Good reference: https://unix.stackexchange.com/questions/145247/understanding-cpu-while-running-top-command

@xxxserxxx
Copy link
Owner Author

It is common and it's used by top/htop, but other resource monitors use gotop's method too like ksysguard. I think it's mostly preference. I personally prefer displaying overall % CPU and I think the default should stay that way, but if we want to add an option or keybind to switch between the two then that sounds good to me!

@xxxserxxx
Copy link
Owner Author

I'd really like to have an option to switch between both ways of showing CPU usage.

@xxxserxxx
Copy link
Owner Author

It seems to me there is more discrepancy than can be explained by the above reason.

I have a VMBox with windows inside running on OSX. gotop showed me max 10% on the VirtualBoxVM provess (mostly around 5%). That would be approx 1 core on my 12 core machine. htop easily goes up to 300-500% (3-5 cores).

Any idea what that could be?

Very nice tool none the less! I love it!

@xxxserxxx
Copy link
Owner Author

@tehsphinx So assuming htop is correctly reporting that information, that discrepancy sounds like a gotop bug and must have something to do with the way we're gather CPU usage information. I'm not immediately sure what that could be, since we're just running ps, so feel free to create an issue for that. I'd also recommend cross referencing the information given with some other resource monitors like top and ksysguard to make sure it's a gotop error.

@xxxserxxx
Copy link
Owner Author

@cjbassi Since this is currently hard to compare (because of the different measuring mentioned in this issue) I'm going wait for the suggested option. Keeping an eye out in the meantime.

@xxxserxxx xxxserxxx added the bug Something isn't working label Feb 19, 2020
@xxxserxxx
Copy link
Owner Author

@suroa FYI

@xxxserxxx xxxserxxx added the needs:review To determine inclusion or wont-fix label Feb 20, 2020
@xxxserxxx xxxserxxx added this to the v4.0.2 milestone Jun 12, 2020
@xxxserxxx
Copy link
Owner Author

xxxserxxx commented Jul 24, 2020

I see two topics in this ticket.

  1. Is gotop's CPU usage correct? There's some indication that it might, in some environments, at least. Correcting this will require building a test, because eyeballing against a different top tool isn't going to cut it.
  2. Provide alternate views for CPU data. I see three possible values:
    1. AVG over all CPU processing power in the machine (already implemented with AVG)
    2. Per-core view. Currently, the labels imply a CPU view when it's really showing cores. This is likely just a label change.
    3. Per-CPU view. This is the sum of the core usage percents per each CPU.

I'm not interested in displaying paradoxical values > 100%. Not only is it a very silly thing, to know how much CPU is really being used, the user still has to do mental math to know what the max value is. Therefore, given:

  • A CPU p
  • Cp, the set of usage percentages, 0-1, of all cores of CPU p
  • |Cp|, the number of cores of CPU p

Then:

2.1 - ∑C/Δt (actually, it should be a rolling average over a time window, so slightly more complex than that)
2.2 - ∀p, ∑Cp
2.3 - ∀p, (∑Cp) / (|Cp|)

So: I'm short-cutting this ticket to the first issue; are the CPU usages reported by gotop correct? The other one, I'll create a feature request for.

@xxxserxxx xxxserxxx modified the milestones: v4.0.2, v4.1.1 Aug 25, 2020
@xxxserxxx xxxserxxx modified the milestones: v4.1.1, v4.1.2 Jan 27, 2021
@dkwo
Copy link

dkwo commented May 14, 2021

I'd also like to report cpu usage different from htop, and inconsistent whitin gotop itself.
1621005405

@xxxserxxx xxxserxxx modified the milestones: v4.1.2, v4.1.3 Jul 20, 2021
@xxxserxxx xxxserxxx modified the milestones: v4.1.3, v4.1.4 Feb 14, 2022
@xxxserxxx xxxserxxx modified the milestones: v4.1.4, v4.1.5 May 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs:review To determine inclusion or wont-fix
Projects
None yet
Development

No branches or pull requests

2 participants