You are not logged in.
Pages: 1
Hi,
Back in my Solaris days we used to try to avoid over using ps as it effectively stalls the kernel whilst is replys to the ps command. Even the 'p' commands had a hit.
To avoid using ps (espically with monitoring tools), we used pid file and lock files. So if we wanted to check the status of process, we'd grab the pid from the pid file, send a
kill -0 [pid]
and check the return.
So, out of interest, I ran some very simple time tests and got these results (I was mostly interested in the sys time here) :
time kill -0 26744 && echo $?
real 0m0.000s
user 0m0.000s
sys 0m0.000s
0
time pgrep gnome-session
26744
real 0m0.013s
user 0m0.002s
sys 0m0.004s
time ps -ef|grep gnome-session
<id> 26744 6282 0 12:16 ? 00:00:00 gnome-session
<id> 26792 26744 0 12:16 ? 00:00:00 /usr/bin/ssh-agent -- gnome-session
<id> 27208 26920 0 12:31 pts/2 00:00:00 grep gnome-session
real 0m0.038s
user 0m0.004s
sys 0m0.010s
(I've removed my id from the above tests, in case you wonder what <id> is)
So from these simple tests, it appears that ps does affect the kernel to a large degree same as on Solaris.
I'm interest to see if you guys agree with this conclusion?
Cheers
Jon
Offline
you could also cat some of the crap in /proc, for comparisson.
still, is this a real issue? I mean, do you really have to worry about such little load?
Offline
Hi,
That depends upon what you are doing. If you are monitoring the system, this load can have an affect, or you at least need to ensure you do not check for processes too much.
Just something to bare in mind really.
Jon
Offline
That depends upon what you are doing. If you are monitoring the system, this load can have an affect, or you at least need to ensure you do not check for processes too much.
Right, I agree. Though for typical users it's not a big deal. I'd say add in the info you can get from /proc/$pid and how "top" or "htop" perform compared to the others and it'd be a real useful wiki article 8)
Offline
Right, I agree. Though for typical users it's not a big deal. I'd say add in the info you can get from /proc/$pid and how "top" or "htop" perform compared to the others and it'd be a real useful wiki article 8)
OK, that sounds like an idea. See if I can knock up something.
Cheers,
Jon
Offline
Pages: 1