What an interesting box you have there...
What an interesting box you have there...
El Belgicano
-----------------
Laptop: 5 years old Asus M6N (ATI9600/9700 graphics, 512Mb RAM, Intel Mobile 1.66GHz, 60Gb HDD) running 10.04-Lucid Lynx pretty nicely.
@El_Belgicano: If you execute mencoder randomly then daemon can be useful, but if you would like to omit only single process and doing this ones per some time, then you do not need cpu_limit daemon script. You can just execute the cpulimit command with process id for mencoder.
@davidparks21: Thanks for bringing this issue out. Limiting processes to 3% is actually very specific problem. In this case it can easily happen that cpulimit program is caught in a 3% cpu limit by deamon. In this case I suggest to whitelist the cpulimit process.
Last edited by abcuser; November 1st, 2011 at 01:15 PM.
Mostly i run mencoder through a script, thus if i follow your thinking, i could change my script from:to:Code:... mencoder [...] & ...and this instance (assuming there are never two mencoders running at the same time) would be limited to 40% cpu without the daemon part having to remind the process it is limited...?Code:... mencoder [...] & cpulimit -e mencoder -l 40 & (exact parameters to be investigated...) ...
Could be good for the pc, i'm looking to trim it's idling ram at a minimum, i'm stuck at 45MB atm... i could save a few more MB's without the daemon...
Thanks for the input...
El Belgicano
-----------------
Laptop: 5 years old Asus M6N (ATI9600/9700 graphics, 512Mb RAM, Intel Mobile 1.66GHz, 60Gb HDD) running 10.04-Lucid Lynx pretty nicely.
In you case I would create a bash file line on destkop or something and then just double click on it to run mencoder.
The code could be something like:
I am sceptical about this statement. I don't think you will preserve much of RAM, specially not mega bytes. But you can test the code and I would be happy to see the results how many RAM you have spare.Code:#!/bin/bash mencoder... PID=$(ps -eo pid | grep "mencoder..." | grep -v grep | gawk '{print $1}') cpulimit -p $PID -l 40 -z
Last edited by abcuser; November 3rd, 2011 at 05:26 PM.
For now i modified my script to:
Now i have two questions:Code:cpulimit -e mencoder -l 25 & mencoder [...] killall cpulimit &
- What if i put two mencoder lines instead of one, would they both respect the speed limit?
- Any idea on how to be more "elegant" than killall? I feel like a butcher now...
Well, without the daemon running i can spare a MB or two while idle... since no unexpected process has to be limited, starting cpulimit when needed sounds lighter...
El Belgicano
-----------------
Laptop: 5 years old Asus M6N (ATI9600/9700 graphics, 512Mb RAM, Intel Mobile 1.66GHz, 60Gb HDD) running 10.04-Lucid Lynx pretty nicely.
In this case then I suggest to use code already discussed on post #14, but in your case use mencoder, like bellow.
Killing is never elegant. I don't see any point of changing this command if it is working fine.Code:#!/bin/bash PIDS=$(ps -eo pid | grep "mencoder" | grep -v grep | gawk '{print $1}') for i in $PIDS do cpulimit -p $i -l 40 -z & done
Interesting findings, thanks for sharing the info. Sparing RAM is very important on netbooks. I have never thought of RAM usage because of having several GB of RAM on PC and I can spare one or two MB.
Is there any hidden advantage to prefer "-p" over "-e"?
Right now i'm using:It's looking like the 20% is being respected for all "mencoder" lines in the speed limited zone... Not done testing though, the script is running right now...Code:function encode() { mencoder [...] (first pass) mencoder [...] (second pass) } cpulimit -e mencoder -l 20 & encode [args1] encode [args2] killall cpulimit &
Then i'll keep feeling like a butcher...
I got 512MB of RAM on that laptop, but for some time now i've been looking to make it as light as possible while idle... Where i'm now, even going from a colored root window to using an image as wallpaper means a change from 42-43 to 45-47 MB (with X, ssh, mpd -paused- and a conky)
Last edited by El_Belgicano; November 5th, 2011 at 06:53 PM.
El Belgicano
-----------------
Laptop: 5 years old Asus M6N (ATI9600/9700 graphics, 512Mb RAM, Intel Mobile 1.66GHz, 60Gb HDD) running 10.04-Lucid Lynx pretty nicely.
Well, I'm no longer having cpulimit its self, but when I checked on cpulimit again today (after running a few days) I see that I have cpulimit processes on 2 of the whitelist processes. I'm perplexed.
I tried taking the base command:
And it does indeed exclude the processes that I see limited.Code:top -b -n1 -c | gawk 'NR>6' | grep -E -v 'my|whitelist|processes'
Before I run off and hack up the script with a ton of debug statements and painfully monitor it for the next few days I thought I'd see if this perks anyones ears.
My configuration on the cpulimit_daemon.sh is below, everything else is out-of-the-box as is laid out in this post.
Code:#!/bin/bash # ============================================================== # CPU limit daemon - set PID's max. percentage CPU consumptions # ============================================================== # Variables CPU_LIMIT=3 # Maximum percentage CPU consumption by each PID DAEMON_INTERVAL=2 # Daemon check interval in seconds BLACK_PROCESSES_LIST= # Limit only processes defined in this variable. If variable is empty (default) all violating processes are limited. WHITE_PROCESSES_LIST="openvpn|squid|log_helper|url_rewrite_helper|ssh|nrpe|cpulimit|statusreader" # Limit all processes except processes defined in this variable. If variable is empty (default) all violating processes are limited.
ps -ef | grep cpulimit
Those PIDsCode:root 5833 32058 0 21:06 ? 00:00:01 cpulimit -p 5774 -l 3 -z root 13439 32058 0 Nov03 ? 00:07:04 cpulimit -p 951 -l 3 -z root 14018 32058 0 Oct31 ? 00:10:18 cpulimit -p 5655 -l 3 -z root 15825 32058 0 Nov01 ? 00:10:07 cpulimit -p 614 -l 3 -z root 20063 32058 0 Nov01 ? 00:09:43 cpulimit -p 1 -l 3 -z root 32657 32058 0 Nov03 ? 00:06:09 cpulimit -p 501 -l 3 -z
Code:1001 5774 5772 0 21:06 pts/0 00:00:01 -bash root 951 1 0 Oct24 ? 00:05:54 /bin/bash /opt/openvpn/bin/statusreader root 5655 1 0 Oct24 ? 00:11:31 /bin/bash /opt/squid/bin/log_helper root 614 1 0 Oct24 ? 00:05:21 /usr/sbin/vnstatd -d root 1 0 0 Oct24 ? 00:36:17 /sbin/init syslog 501 1 0 Oct24 ? 00:06:35 rsyslogd -c5
This is strange problem, I never faced the problem of this kind. Did you change some WHITE_PROCESSES_LIST variable like adding "openvpn" string to the variable and forgot to restart daemon?
=== From first post of this thread ===
Restart cpulimit service
If you change some variables settings in /usr/bin/cpulimit_daemon.sh like CPU_LIMIT, DAEMON_INTERVAL, BLACK_PROCESSES_LIST or WHITE_PROCESSES_LIST, then after changing settings you must restart service.
Code:sudo service cpulimit restart
Last edited by abcuser; November 8th, 2011 at 05:57 PM.
Bookmarks