Best way to renice a process by name?

2006-09-26 Thread Brett Glass
I'm working with a machine that's operating as a NAT router and 
recursive DNS resolver and is also running the Squid disk cache. 
Squid, in turn, spawns the diskd daemon, which does disk accesses 
on behalf of Squid. When Squid spawns diskd, it gives it a priority 
level 6 greater than itself. In other words, if Squid is launched 
normally, it gets a priority of 2 (normal) while diskd gets a 
priority of -4 (very high).


Unfortunately, diskd is not an efficient user of CPU (it seems to 
be polling for I/O completion) and is starving other processes on 
the machine (for example, natd) which need to operate in near real time.


I'd like to keep diskd running on that machine, because having disk 
access done by a separate process is very efficient -- even more so 
if the system uses SMP. But I need to re-prioritize Squid and diskd 
to keep the rest of the machine functional. In particular, I'd like 
to nice Squid down by 1 (so that natd and named have priority over 
it) and have diskd run at standard priority (so that it can't 
starve other processes). This will keep diskd at a higher priority 
than Squid itself, which in turn will hopefully prevent message 
queues from overflowing.


Reducing Squid's priority is simple; I can just edit the script 
that starts Squid so that /usr/bin/nice is used to invoke it. But 
taming diskd is more difficult, because diskd is a child process of 
Squid. I have to make sure it has started (which may require a 
delay loop), find out its PID, and then renice it by whatever 
increment is required to get it to the system's standard priority 
(2 by convention). Is there a renice by name utility for FreeBSD 
(sort of an equivalent of killall)? I could gin one up, but since 
this seems like something that people would want to do frequently, 
find it hard to believe that someone hasn't already written one.


--Brett Glass

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Best way to renice a process by name?

2006-09-26 Thread Philip Hallstrom
I'm working with a machine that's operating as a NAT router and recursive DNS 
resolver and is also running the Squid disk cache. Squid, in turn, spawns the 
diskd daemon, which does disk accesses on behalf of Squid. When Squid 
spawns diskd, it gives it a priority level 6 greater than itself. In other 
words, if Squid is launched normally, it gets a priority of 2 (normal) while 
diskd gets a priority of -4 (very high).


Unfortunately, diskd is not an efficient user of CPU (it seems to be polling 
for I/O completion) and is starving other processes on the machine (for 
example, natd) which need to operate in near real time.


I'd like to keep diskd running on that machine, because having disk access 
done by a separate process is very efficient -- even more so if the system 
uses SMP. But I need to re-prioritize Squid and diskd to keep the rest of the 
machine functional. In particular, I'd like to nice Squid down by 1 (so that 
natd and named have priority over it) and have diskd run at standard priority 
(so that it can't starve other processes). This will keep diskd at a higher 
priority than Squid itself, which in turn will hopefully prevent message 
queues from overflowing.


Reducing Squid's priority is simple; I can just edit the script that starts 
Squid so that /usr/bin/nice is used to invoke it. But taming diskd is more 
difficult, because diskd is a child process of Squid. I have to make sure it 
has started (which may require a delay loop), find out its PID, and then 
renice it by whatever increment is required to get it to the system's 
standard priority (2 by convention). Is there a renice by name utility for 
FreeBSD (sort of an equivalent of killall)? I could gin one up, but since 
this seems like something that people would want to do frequently, find it 
hard to believe that someone hasn't already written one.


Google is your friend :)

http://www.google.com/search?q=reniceall

very first link.
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Best way to renice a process by name?

2006-09-26 Thread Garance A Drosihn

At 9:32 AM -0600 9/26/06, Brett Glass wrote:


Is there a renice by name utility for FreeBSD (sort of an 
equivalent of killall)? I could gin one up, but since this seems 
like something that people would want to do frequently, find it hard 
to believe that someone hasn't already written one.


FreeBSD added the `pgrep' command sometime ago.  Your renice-by-name
script would turn into something like:

renice +2 `pgrep diskd`

(I have not tested that, and you might want to embellish it by adding
some of the other options to the `pgrep' command)

--
Garance Alistair Drosehn=   [EMAIL PROTECTED]
Senior Systems Programmer   or  [EMAIL PROTECTED]
Rensselaer Polytechnic Instituteor  [EMAIL PROTECTED]
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Best way to renice a process by name?

2006-09-26 Thread Giorgos Keramidas
On 2006-09-26 09:32, Brett Glass [EMAIL PROTECTED] wrote:
 I'm working with a machine that's operating as a NAT router and
 recursive DNS resolver and is also running the Squid disk cache.
 Squid, in turn, spawns the diskd daemon, which does disk accesses on
 behalf of Squid. When Squid spawns diskd, it gives it a priority level
 6 greater than itself. In other words, if Squid is launched normally,
 it gets a priority of 2 (normal) while diskd gets a priority of -4
 (very high).

 Unfortunately, diskd is not an efficient user of CPU (it seems to be
 polling for I/O completion) and is starving other processes on the
 machine (for example, natd) which need to operate in near real time.

 I'd like to keep diskd running on that machine, because having disk
 access done by a separate process is very efficient -- even more so if
 the system uses SMP. But I need to re-prioritize Squid and diskd to
 keep the rest of the machine functional. In particular, I'd like to
 nice Squid down by 1 (so that natd and named have priority over it)
 and have diskd run at standard priority (so that it can't starve other
 processes). This will keep diskd at a higher priority than Squid
 itself, which in turn will hopefully prevent message queues from
 overflowing.

 Reducing Squid's priority is simple; I can just edit the script that
 starts Squid so that /usr/bin/nice is used to invoke it. But taming
 diskd is more difficult, because diskd is a child process of Squid. I
 have to make sure it has started (which may require a delay loop),
 find out its PID, and then renice it by whatever increment is
 required to get it to the system's standard priority (2 by
 convention). Is there a renice by name utility for FreeBSD (sort of
 an equivalent of killall)? I could gin one up, but since this seems
 like something that people would want to do frequently, find it hard
 to believe that someone hasn't already written one.

Maybe something like this helps?

$ echo renice -n +10 -p `echo \`pgrep httpd\` | sed -e 's/ /,/g'`
renice -n +10 -p 1023,656,655,654,653,652,610
$

There is always a fair chance you might attempt to renice a process
which just happened to die, but this should be ok, unless you start
seeing PIDs being recycled too fast :)

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]