ps and top give different CPU usage
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
linux top ps
add a comment |
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
linux top ps
You meanps
never ever changes and is always 2.2? Could you post the output ofps
andtop
for the command in question so we can have a look?
– terdon
Sep 10 '13 at 13:18
@terdon I updated the original post with additional information.
– TTT
Sep 11 '13 at 13:16
add a comment |
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
linux top ps
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
linux top ps
linux top ps
edited Mar 20 '17 at 10:17
Community♦
1
1
asked Sep 10 '13 at 12:40
TTTTTT
182214
182214
You meanps
never ever changes and is always 2.2? Could you post the output ofps
andtop
for the command in question so we can have a look?
– terdon
Sep 10 '13 at 13:18
@terdon I updated the original post with additional information.
– TTT
Sep 11 '13 at 13:16
add a comment |
You meanps
never ever changes and is always 2.2? Could you post the output ofps
andtop
for the command in question so we can have a look?
– terdon
Sep 10 '13 at 13:18
@terdon I updated the original post with additional information.
– TTT
Sep 11 '13 at 13:16
You mean
ps
never ever changes and is always 2.2? Could you post the output of ps
and top
for the command in question so we can have a look?– terdon
Sep 10 '13 at 13:18
You mean
ps
never ever changes and is always 2.2? Could you post the output of ps
and top
for the command in question so we can have a look?– terdon
Sep 10 '13 at 13:18
@terdon I updated the original post with additional information.
– TTT
Sep 11 '13 at 13:16
@terdon I updated the original post with additional information.
– TTT
Sep 11 '13 at 13:16
add a comment |
2 Answers
2
active
oldest
votes
The likeliest reason is that top
shows the percentage values as a percentage of a single CPU while ps
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.
Yes, I'm running on 12 cores. That does reduce the % levels that it reaches intop
such that the average value is below that ofps
, so that may be the difference. The process is a lot less active now, though, so it's hard to say...
– TTT
Sep 11 '13 at 15:48
1
@TTT this is a classic issue, it used to drive me up the wall before I discovered the shift+I thing.
– terdon
Sep 11 '13 at 17:18
add a comment |
This question is old, but in my opinion the answer is incorrect. ps and top calculates CPU usage using different methods.
from man top:
- %CPU -- CPU Usage
The task's share of the elapsed CPU time since the last screen update, expressed as a percentage of total CPU time.
from man ps:
CPU usage is currently expressed as the percentage of time spent
running during the entire lifetime of a process.
So, lets say you have a process that was started a week ago and during that time it used 2.2% of CPU time on average. If suddenly it would became CPU intensive ( constantly consuming 100%) - looking at ps you would observe same 2.2% for the first few hours.
You're half-right in this case, sincemaui
runs continuously in the background. But, even ifps
andtop
averaged over the same time period, there'd still be a 12x difference because of the issue noted by the accepted answer. So, both answers are partially correct.
– TTT
Jan 12 at 15:25
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f643331%2fps-and-top-give-different-cpu-usage%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
The likeliest reason is that top
shows the percentage values as a percentage of a single CPU while ps
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.
Yes, I'm running on 12 cores. That does reduce the % levels that it reaches intop
such that the average value is below that ofps
, so that may be the difference. The process is a lot less active now, though, so it's hard to say...
– TTT
Sep 11 '13 at 15:48
1
@TTT this is a classic issue, it used to drive me up the wall before I discovered the shift+I thing.
– terdon
Sep 11 '13 at 17:18
add a comment |
The likeliest reason is that top
shows the percentage values as a percentage of a single CPU while ps
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.
Yes, I'm running on 12 cores. That does reduce the % levels that it reaches intop
such that the average value is below that ofps
, so that may be the difference. The process is a lot less active now, though, so it's hard to say...
– TTT
Sep 11 '13 at 15:48
1
@TTT this is a classic issue, it used to drive me up the wall before I discovered the shift+I thing.
– terdon
Sep 11 '13 at 17:18
add a comment |
The likeliest reason is that top
shows the percentage values as a percentage of a single CPU while ps
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.
The likeliest reason is that top
shows the percentage values as a percentage of a single CPU while ps
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.
edited Mar 20 '17 at 10:16
Community♦
1
1
answered Sep 11 '13 at 13:28
terdonterdon
41.5k887136
41.5k887136
Yes, I'm running on 12 cores. That does reduce the % levels that it reaches intop
such that the average value is below that ofps
, so that may be the difference. The process is a lot less active now, though, so it's hard to say...
– TTT
Sep 11 '13 at 15:48
1
@TTT this is a classic issue, it used to drive me up the wall before I discovered the shift+I thing.
– terdon
Sep 11 '13 at 17:18
add a comment |
Yes, I'm running on 12 cores. That does reduce the % levels that it reaches intop
such that the average value is below that ofps
, so that may be the difference. The process is a lot less active now, though, so it's hard to say...
– TTT
Sep 11 '13 at 15:48
1
@TTT this is a classic issue, it used to drive me up the wall before I discovered the shift+I thing.
– terdon
Sep 11 '13 at 17:18
Yes, I'm running on 12 cores. That does reduce the % levels that it reaches in
top
such that the average value is below that of ps
, so that may be the difference. The process is a lot less active now, though, so it's hard to say...– TTT
Sep 11 '13 at 15:48
Yes, I'm running on 12 cores. That does reduce the % levels that it reaches in
top
such that the average value is below that of ps
, so that may be the difference. The process is a lot less active now, though, so it's hard to say...– TTT
Sep 11 '13 at 15:48
1
1
@TTT this is a classic issue, it used to drive me up the wall before I discovered the shift+I thing.
– terdon
Sep 11 '13 at 17:18
@TTT this is a classic issue, it used to drive me up the wall before I discovered the shift+I thing.
– terdon
Sep 11 '13 at 17:18
add a comment |
This question is old, but in my opinion the answer is incorrect. ps and top calculates CPU usage using different methods.
from man top:
- %CPU -- CPU Usage
The task's share of the elapsed CPU time since the last screen update, expressed as a percentage of total CPU time.
from man ps:
CPU usage is currently expressed as the percentage of time spent
running during the entire lifetime of a process.
So, lets say you have a process that was started a week ago and during that time it used 2.2% of CPU time on average. If suddenly it would became CPU intensive ( constantly consuming 100%) - looking at ps you would observe same 2.2% for the first few hours.
You're half-right in this case, sincemaui
runs continuously in the background. But, even ifps
andtop
averaged over the same time period, there'd still be a 12x difference because of the issue noted by the accepted answer. So, both answers are partially correct.
– TTT
Jan 12 at 15:25
add a comment |
This question is old, but in my opinion the answer is incorrect. ps and top calculates CPU usage using different methods.
from man top:
- %CPU -- CPU Usage
The task's share of the elapsed CPU time since the last screen update, expressed as a percentage of total CPU time.
from man ps:
CPU usage is currently expressed as the percentage of time spent
running during the entire lifetime of a process.
So, lets say you have a process that was started a week ago and during that time it used 2.2% of CPU time on average. If suddenly it would became CPU intensive ( constantly consuming 100%) - looking at ps you would observe same 2.2% for the first few hours.
You're half-right in this case, sincemaui
runs continuously in the background. But, even ifps
andtop
averaged over the same time period, there'd still be a 12x difference because of the issue noted by the accepted answer. So, both answers are partially correct.
– TTT
Jan 12 at 15:25
add a comment |
This question is old, but in my opinion the answer is incorrect. ps and top calculates CPU usage using different methods.
from man top:
- %CPU -- CPU Usage
The task's share of the elapsed CPU time since the last screen update, expressed as a percentage of total CPU time.
from man ps:
CPU usage is currently expressed as the percentage of time spent
running during the entire lifetime of a process.
So, lets say you have a process that was started a week ago and during that time it used 2.2% of CPU time on average. If suddenly it would became CPU intensive ( constantly consuming 100%) - looking at ps you would observe same 2.2% for the first few hours.
This question is old, but in my opinion the answer is incorrect. ps and top calculates CPU usage using different methods.
from man top:
- %CPU -- CPU Usage
The task's share of the elapsed CPU time since the last screen update, expressed as a percentage of total CPU time.
from man ps:
CPU usage is currently expressed as the percentage of time spent
running during the entire lifetime of a process.
So, lets say you have a process that was started a week ago and during that time it used 2.2% of CPU time on average. If suddenly it would became CPU intensive ( constantly consuming 100%) - looking at ps you would observe same 2.2% for the first few hours.
answered Jan 2 at 21:12
trukttrukt
211
211
You're half-right in this case, sincemaui
runs continuously in the background. But, even ifps
andtop
averaged over the same time period, there'd still be a 12x difference because of the issue noted by the accepted answer. So, both answers are partially correct.
– TTT
Jan 12 at 15:25
add a comment |
You're half-right in this case, sincemaui
runs continuously in the background. But, even ifps
andtop
averaged over the same time period, there'd still be a 12x difference because of the issue noted by the accepted answer. So, both answers are partially correct.
– TTT
Jan 12 at 15:25
You're half-right in this case, since
maui
runs continuously in the background. But, even if ps
and top
averaged over the same time period, there'd still be a 12x difference because of the issue noted by the accepted answer. So, both answers are partially correct.– TTT
Jan 12 at 15:25
You're half-right in this case, since
maui
runs continuously in the background. But, even if ps
and top
averaged over the same time period, there'd still be a 12x difference because of the issue noted by the accepted answer. So, both answers are partially correct.– TTT
Jan 12 at 15:25
add a comment |
Thanks for contributing an answer to Super User!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f643331%2fps-and-top-give-different-cpu-usage%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
You mean
ps
never ever changes and is always 2.2? Could you post the output ofps
andtop
for the command in question so we can have a look?– terdon
Sep 10 '13 at 13:18
@terdon I updated the original post with additional information.
– TTT
Sep 11 '13 at 13:16