Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

Preventing a hog-process from eating up your CPU cycles.

Share your HowTo, Documentation, Tips and Tricks. Not for support questions!.
Post Reply
Message
Author
User avatar
edbarx
Posts: 5401
Joined: 2007-07-18 06:19
Location: 35° 50 N, 14 º 35 E
Been thanked: 2 times

Preventing a hog-process from eating up your CPU cycles.

#1 Post by edbarx »

cpulimit is a simple cpu usage limiter for processes. Some programs eat far too many CPU cycles for what they do. This tool comes in handy in such a situation.

For multicore processors the allowable percentage is 100n, where n is the number of processor cores. So, if you own a quad-core processor, it would mean the allowable percentage is 400%.

The following assumes a single core processor:
Suppose process cpu_gobbler is eating 100% of your CPU cycles (and you cannot figure out why it should do so). You can 'educate' cpu_gobbler to behave by using cpulimit in this way, obviously, after starting cpu_gobbler.

After starting cpu_gobbler use top to find its process ID. Let us assume the latter is 4112. Then, issue this simple command:

Code: Select all

cpulimit -p 4112 -l 10 -z
Where:
  1. -p precedes the process ID
  2. -l precedes the percentage of CPU cycles to be allowed (el not one!)
  3. -z tells cpulimit to terminate as soon as cpu_gobbler dies/terminates
Instead of the proces ID you can use the executable's file name. This is achieved using the switch:

Code: Select all

 --exe=cpu_gobbler
For further details, if any, consult the manpage as it is one of the easiest to understand.

P.S.:
I am using cpulimit on MS Skype :P :mrgreen:.
Last edited by edbarx on 2014-05-29 16:14, edited 3 times in total.
Debian == { > 30, 000 packages }; Debian != systemd
The worst infection of all, is a false sense of security!
It is hard to get away from CLI tools.

User avatar
argorain
Posts: 58
Joined: 2014-04-15 05:31
Location: CR
Contact:

Re: Preventing a hog-process from eating up your CPU cycles.

#2 Post by argorain »

Great tip, thanks.
Vojtech "Rain" Vladyka

User avatar
edbarx
Posts: 5401
Joined: 2007-07-18 06:19
Location: 35° 50 N, 14 º 35 E
Been thanked: 2 times

Re: Preventing a hog-process from eating up your CPU cycles.

#3 Post by edbarx »

For those interested, I am using cpulimit with -l 17 for Skype on an Intel T4400 2.2GHz CPU! Obviously, I have video disabled. This means, I am running Skype with only 8.5% of my computer's power. 8)
Debian == { > 30, 000 packages }; Debian != systemd
The worst infection of all, is a false sense of security!
It is hard to get away from CLI tools.

Post Reply