You are not logged in.

#1 2005-11-11 12:42:16

jondkent
Member
From: London
Registered: 2005-09-13
Posts: 123

Is ps kernel friendly?

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

#2 2005-11-11 16:43:59

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: Is ps kernel friendly?

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

#3 2005-11-11 22:08:19

jondkent
Member
From: London
Registered: 2005-09-13
Posts: 123

Re: Is ps kernel friendly?

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

#4 2005-11-11 22:26:58

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: Is ps kernel friendly?

jondkent wrote:

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

#5 2005-11-11 22:33:02

jondkent
Member
From: London
Registered: 2005-09-13
Posts: 123

Re: Is ps kernel friendly?

phrakture wrote:

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

Board footer

Powered by FluxBB