Back to Soundstation main

Soundstation: 4 - CPU throttling & Co.


Everything is working quite well. Both listening to the musinc using Amarok or watching divx/xvid movies using Mplayer (see the next section for informations about the setup I'm using) generates in both cases on the VIA Epia SP80000 a CPU usage of about 20%. The only thing is that when using lame to generate the MP3-files, they're generated only at about 1.7x, which is quite slow, and additionally the CPU gets after some time quite warm (65C).
Therefore, it would be nice to:

  • use CPU throttling to slow down the clock when the PC is not used. This should cool down the machine a little bit.
  • speed up the process of generating MP3-files.


4a - CPU throttling
I managed to make it work the following way:

  • Go to the VIA homepage, search for the update of the drivers for the Linux Kernel (I found them under C3 & C7 processor features and downloaded for my Gentoo distribution the version Fedora 2/3/4/5/6 & Mandriva 10/10.1/10.2/2006/2007 0.83b). I saved the package as well here, just in case it disappears for any reason from the official homepage :oP

  • Read the instructions contained in the file. Replace the longhaul.* files of the linux kernel with the ones contained in the package, select the appropriate options in the kernel configuration, recompile and install it - should be done in 15 minutes.

  • After restarting the PC, have a look at the contents of the directories /sys/devices/system/cpu/cpu0/cpufreq/ and /sys/devices/system/cpu/cpu0/cpufreq/stats. After issuing a...
    cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
...you should see that the userspace governor is active, as it was suggested by the guide.

  • Now, to change the throttling of the CPU, you can choose to use the utility delivered by VIA, or adopt other solutions. I personally wanted to have an automatic throttling, depending on how much CPU power is needed by the applications.
    • VIA utility: was a little bit unstable on my PC. It had the auto mode selected, but after each restart I had to re-select it to make it active. It was interesting to see that the directory /sys/devices/system/cpu/cpu0/cpufreq/stats/ disappeared after starting this utility, and had to reboot in order to make it appear again.
    • ondemand governor: works until the X server is started - then everything hangs for a few minutes and X crashes. I think that probably this governor switches clock too often, and the CPU doesn't support it.
    • powersave governor: this one sets the CPU clock to the minimum, which is 532 Mhz for the VIA Epia SP80000. I didn't try it out, but it should work.
    • performance governor: same as above, but sets the clock to its maximum, which is 798 Mhz.
    • userspace governor: needed only if the clock has to be adjusted by an external application, as the VIA utility.
    • conservative governor: same as the ondemand governor, but with much slower clock switches. I used this one by setting during boot:
      echo conservative > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor

  • After having set the conservative governor, you can check with...
    cat /sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state
...for how much time each of the CPU frequencies was used.



4b - Speed up generation of MP3-files
This is not an easy task.

I first tried (again) to compile Lame using different CFLAGS and afterwards compress always the same song. I tried with -march=c3-2, -march=i686, -Os, -O2 and -O3. I obtained the best results with -O2, but it increased the speed only from ~1.6x to ~1.7x. I didn't notice any difference between using -march=i686 and -march=c3-2.

Luckily there is a program called gogo, which is an optimized version of Lame, taking advantage of the MMX/SSE/CMOV, etc... functionalities of the CPU.
I therefore emerged Gogo, and after some test (I compared the MP3 vs. original version of the MIB song, which is very simple and with a lot of bass and Mando Diao, which has a lot of voice mixed up with guitar and drums) I configured abcde to use the settings...

GOGOOPTS="-m j -q 1 -b 192"

...and now it is encoding at 2.4x. Nice :o)


Chapter 1 - Theory & hardware
Chapter 2 - Initial setup
Chapter 3 - Jukebox music setup
Chapter 4 - CPU throttling & Co. <= You are here
Chapter 5 - Watch movies
Back to Soundstation main