-
Notifications
You must be signed in to change notification settings - Fork 55
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
Inaccurate CPU usage on multi-threaded processes #58
Comments
ping @simonepri |
Can you better describe what you mean by "heavily multi-threaded"? Please provide:
|
Can you please also provide the output of: ps -o etime,pid,ppid,pcpu,rss,time Thank you! |
I ran that command with the PID of the process being monitored supplied as an argument (19918), and this is the output :
|
Hi @kittyhacker101! @soyuka the man page does not talk about multi-threaded process but I guess that the percentage returned is up to If that is true for all platforms, the correct formula would be: |
@simonepri I guess that the formula there is indeed correct! Do you think that we should patch the library to take this into consideration? Thing is, sometimes you're monitoring a single-threated process (ie javascript thread) therefore it should not use the above formula, or results won't reflect the reality... |
I believe that we need this #57 {
cpu: pcpu / os.cpus().length, // Percentage (0 - 100)
threads: 5, // Number of threads of the process
memory: 357306368, // bytes
ppid: 312, // PPID
pid: 727, // PID
ctime: 867000, // ms user + system time
elapsed: 6650000, // ms since the start of the process
timestamp: 864000000 // ms since epoch
} Then for instance if pidusage returns something like that: {
cpu: 25,
threads: 2,
[...]
} And our system has 4 vcore. We can interpret the reading as: |
@soyuka
|
So, I wrote my own snippet to detect CPU usage ( |
Yes sorry, distraction error, actually the correct formula should be just: I've updated all the comments with the correct formula. |
Oh, okay. |
It's silly after a second though. It'd be great to have the thread count as an additional information indeed.. Maybe we could partially support them on OSes that work? Anyway thanks for the report @kittyhacker101 and for looking into this @simonepri ! |
Available in |
@kittyhacker101 can you confirm that the bug is solved? |
The bug in question is solved, but due to this library's averaging of the CPU usage, it takes a while for it to show the correct value (making it less useful). |
Could you better explain what "a while" means? It should be really fast on linux. |
By "a while", I mean it could take 2+ minutes to adjust to the correct CPU usage. |
That's weird. Thank You for the help! |
hi, i hava a querstion about cpu in lib/ps.js. |
When a multi-threaded process is putting a low load on many cores, this library will show the CPU usage as 100%.
The text was updated successfully, but these errors were encountered: