PDA

View Full Version : suggestion: negative nice startup



bill fumerola
2005-05-18, 02:58
any chance/interest in seeing the script that spawns slimserver on
unix-ish platforms do so optionally with a negative nice value? gui
configurable would be nice but even a hard-coded '-1' would do.

processes with fairly constant i/o (like slimserver) will be prioritized
lower than more interactive processes. normally this works fine,
interactive processes yield a lot and slimserver still gets what it
needs. however, a process that goes from being interactive to spinning
cpu will initially get more time slices. example: a dvd encoding tool
that goes from a configuration mode to churning through the latest codec.
eventually they'll both be scheduled fairly, but by that time the audio
has already skipped. simpler example: start a compile of something with
a bunch of files (extra fun: use 'make -j').

because i'm truely lazy, i just run a root crontab that renices slimserver
(and eyetv) periodically. it's easier than re-editing the various startup
scripts after upgrades. i can still run slimserver & eyetv reniced as
an unprivileged user with no change to either. regardless of how
right/wrong i am with the scheduler theory: i do see a reduction in the
number of different workloads that can cause a stall with slimserver
running renice'd negatively.

the most straightforward change would to execute sudo with a user supplied
nice value defaulting to zero. nice values are inherited through sudo's
execve().

a slightly more complicated way to solve this would be to introduce a
pidfile. using a pidfile makes it easy to renice after startup. as a
bonus, it is more precise for checking if slimserver is running in the
[re]start/stop scripts. the existing use of ps|grep has a few not-so-subtle
races.

i'd prefer someone who could do the corresponding gui change would
champion this. perl and i rarely get along. if there's interest, i'll
take a shot at drafting a patch. if not, i'll just continue to carry my
private little hack.

-- bill

jth
2005-05-18, 07:17
I'm pretty sure the slimserver will be able to do what you want
already.

Take a look at the --priority option. You'll have to start the
server as root to use this, so also use --user and --group to
change the effective ids of the server after it starts.

There's also a --pidfile option as well if you prefer.

bill fumerola
2005-05-18, 10:20
On Wed, May 18, 2005 at 07:17:47AM -0700, jth wrote:
> Take a look at the --priority option. You'll have to start the
> server as root to use this, so also use --user and --group to
> change the effective ids of the server after it starts.

editing scripts that i don't want to have to do every time i upgrade...

> There's also a --pidfile option as well if you prefer.

ok, that brings up a better question: why isn't that the default?

i ask because i pity the poor bastard named 'david slim' (username
'slimd') who gets some random process rolled over by the stop script.
i'd be angry if some user started a process called slimdevicesrules.sh
and then my slimserver wouldn't start because there's already a "server
running". tough luck to someone trying to stop their slimserver running
as user 'grep'!

i could come up with more contrived examples, but the point is that using
a pidfile by default would avoid these and similar problems.

-- bill fumerola