[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Limiting a processe's cpu%, not cputime.



Hi,

I've seen this question over and over in forums and the answers seem
to be the same. My cpu doesn't get too much action other than gkrellmd
and X, seldom above 50% usage. The issue is, if i want to encode from
wav to ogg, the cpu hits 100% easy while it's encoding. What i want is
to tell oggenc not to use more than 75% of the cpu processing power.
Why? 'Cos i want to :) And it doesn't seem wise to let the cpu toast
away for long periods of time, plus the cpu fan will soon fail (i'm in
the process of replacing it but the question prevails). It's a similar
issue with running seti@home and alike, which i don't, but i do leave
my computer on 24/7.

The first suggestion seems to be re/nice, which doesn't apply. If most
of the processes are idle ones, oggenc will still get 100%. There's
AND[1], but that's just automating nice anyway.

What i tried next was cpulimit. Such as:
#oggenc -m 192 file.wav
in one terminal and
#cpulimit -e oggenc -l=95
in another terminal as root. It's supposed to limit the process to 95%
of cpu load but, in fact, it just stops the process alltoguether. If i
Ctrl+C cpulimit, oggenc resumes, at 100%.

Other suggestions are using limits or ulimit but those limit the user,
not the process. Alternatives could be running oggenc as another user,
using shell scrips to constantly stop/start the process, creating
processes that idle the CPU and balancing that with oggenc, etc,
etc... Neither seems very practical or elegant.

From some searches and the Deb archive i came across a kernel patch[2]
that seems to do just what i want: to limit the amount of cpu% a
process can use. The thing is, i'm rather "allergic" to messing with
kernels (other than through apt). Does anyone have any experience with
this patch or suggests an alternative (other than not encoding files,
i'd like technical answers, not biased opinions please)?

[1] http://and.sourceforge.net/
[2] http://www.tls-technologies.com/CPU/cpu-intro.html

My system is a Debian unstable; CPU: AMD Athlon64 3500+; kernel: 2.6.26-1-amd64

TIA
Nuno Magalhães

Reply to: