Making ‘ondemand’ CPU frequency scaling more responsive

For a while now I’ve found that ondemand CPU frequency scaling (enabled by default) makes my laptop seem sluggish under Ubuntu.

Basically the CPU speed doesn’t seem to increase quickly enough to keep up with the sudden brief bursts of demand caused when using Gmail, or playing Youtube videos for instance. Applying information found on this website seems to give a more responsive system.

echo 1 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/ignore_nice_load
echo 40 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/up_threshold

This changes the default behaviour of the ondemand governor to force it to take into account background processes, and tells it to increase CPU speed when your CPU usage exceeds 40% rather than 95% (as is default).

Because /sys/ is a virtual file system created each time you boot your system, any changes you make are lost after a restart. Add the lines above to /etc/rc.local (read here for more on rc.local) to have your chosen settings applied each time you start Ubuntu.

Have fun.

Posted by Chris

Post to del.icio.us Post to del.icio.us

Post to Slashdot Post to Slashdot

Digg this Digg this

This entry was posted on Tuesday, May 12th, 2009 at 10:28 pm and is filed under Tags: , . You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

6 Responses to “Making ‘ondemand’ CPU frequency scaling more responsive”

  1. kendon Says:

    thx for the hint, this new behaviour annoyed the crap out of me too.

    two comments though:
    would be nice if you give the commands in “code box” or something as script, so a reader (me ;) can just c&p it into a file. but that’s just a remark, no critizism here.
    when i tried the commands on my system it responded with “/sys/devices/system/cpu/cpu0/cpufreq/ondemand/ignore_nice: No such file or directory”. the file is called ignore_nice_load on my system, i am using ubuntu jaunty, maybe you have cut some text of your command? doesn’t seem obvious to me why the filename should differ on systems.

  2. Chris Says:

    Ah, it seems I missed ‘_load’ from the end of that file. I’ve edited the tutorial above to reflect that now! I’ve also put the commands in a code box and added some info on how to force these settings to apply at each boot.

  3. kendon Says:

    awesome ;)

    would be nice to have it somewhere in your home-directory AND have it executed by default, in terms of keeping the setting for an upgrade/reinstallation. but i guess a script in ~/ does it aswell.

  4. Slate8 Says:

    Great little article. Have tried it myself but get “denied” messages when trying this on 9.04. Even running as sudo didn’t help. Finally I tried sudo su, then ran the commands and it works! woo!

    I have added the lines into /etc/rc.local but it does not seem to kick in on boot (presumably because of permissions). Any suggestions how I might get this working on each boot?

    Thanks again.

  5. Chris Says:

    Hi Slate8,

    Check out this blog post to read how to set a script to run at boot time. http://embraceubuntu.com/2005/09/07/adding-a-startup-script-to-be-run-at-bootup/

    Chris

  6. Como hacer que Ubuntu en tu laptop sea mucho más rápido « El rincon de Mozyto Says:

    [...] Fuente: Making ‘ondemand’ CPU frequency scaling more responsive [...]

Leave a Reply