I've seen a few posts similar to this, most notably here, but wasn't quite satisfied with the answers. I'm comparing top
and ps
results on a specific process and see huge discrepancies in CPU usage. top
varies between <1% and 100% from interval to interval including periods of sustained highs (>50% for 3-4 intervals), while ps
is steady at 2.2%. The process I'm watching doesn't have any children or anything, so I'm not quite sure what to make of it. Since there are sustained high periods in top
, I feel I can rule out sampling interval.
Is this really just a discrepancy in how these two tools handle I/O wait time, as suggested by the question I linked to above?
EDIT:
I've seen it fluctuate to 2.1% in ps
, but that's it so far. Output from top -p 4522
:
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
4522 root 16 0 340m 316m 4732 R 54.7 1.3 508:57.46 maui
Output from ps u -p 4522
:
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 4522 2.2 1.3 348764 324456 ? Ss Aug25 509:25 /usr/local/maui/sbin/maui
Best Answer
The likeliest reason is that
top
shows the percentage values as a percentage of a single CPU whileps
shows the percentage of total available CPU power. Try running top and hitting ShiftI while it's running to show the percentage of all cores.If this is a server cluster with a lot of CPUs, what you describe is normal behavior. Also see here.