Confirmation of the rigor of the calculation method of the threads and process CPU metrics #340
Unanswered
wuzengshun
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
By reading the source code of pidstat, I found out how these metrics are calculated:
The above calculation method is correct for threads. But for processes, I'm not sure if there will be errors.
For processes, I guess it might be more accurate to look like this:
Here's some info on utime and stime:
https://stackoverflow.com/questions/46317296/do-the-cutime-and-cstime-jiffies-include-the-child-processes-as-well
Therefore, according to the current implementation, the running time of the thread that has exited is not counted into the running time of the process. Only all currently alive threads are counted.
kernel code:
Beta Was this translation helpful? Give feedback.
All reactions