cpu frequency scaling

Optimize your system for ultimate performance.

Moderators: MattKingUSA, khz

User avatar
autostatic
Established Member
Posts: 1994
Joined: Wed Dec 09, 2009 5:26 pm
Location: Beverwijk, The Netherlands
Has thanked: 32 times
Been thanked: 104 times
Contact:

Re: cpu frequency scaling

Post by autostatic »

morko wrote:I have a laptop that runs quite hot so I didn't want to use the "performance" governor. The "conservative" governor works fine for me. I think it doesn't change the frequency so rapidly and I'm not getting xruns because of it. You might want to try it if you dont want your cpu running at full power all the time. Or then you can bore yourself making your own governors. ;)
I think the switching of CPU frequencies causes xruns or issues with JACK. If you keep your CPU on a constant frequency JACK might not complain. Never tested this though.
SR
Established Member
Posts: 218
Joined: Wed May 07, 2008 6:01 pm
Location: Houston, Tx

Re: cpu frequency scaling

Post by SR »

It makes a difference for me. With my laptop on "ondemand" I had some predictable xruns from Yoshimi that I could only get rid of by increasing the latency. Setting it for "performance" gets rid of the xruns.
User avatar
horo
Established Member
Posts: 28
Joined: Tue May 19, 2009 8:45 pm
Location: Berlin & Ingolstadt, Germany

Re: cpu frequency scaling

Post by horo »

Hi,

the issues with frequency scaling were discussed last year at LAD: http://old.nabble.com/JACK-and-computer ... 52208.html
Paul Davis wrote:
If you are using JACK, do not let your computer sleep, or suspend, or engage in CPU frequency scaling. These all appear to JACK as indistinguishable from your audio interface ceasing to function in a way that leads it to quit or die. Remember that JACK is watching the passing of absolute time.
Ciao Martin
User avatar
Scary Hallo
Established Member
Posts: 280
Joined: Fri Oct 23, 2009 2:21 pm
Location: Germany / Pforzheim
Contact:

Re: cpu frequency scaling

Post by Scary Hallo »

Does anybody figure out, how to set it permanently to 'performace' in Ubuntu 10.4?
morko
Established Member
Posts: 45
Joined: Thu Mar 25, 2010 8:08 am
Location: Finland

Re: cpu frequency scaling

Post by morko »

AutoStatic wrote: morko wrote:I have a laptop that runs quite hot so I didn't want to use the "performance" governor. The "conservative" governor works fine for me. I think it doesn't change the frequency so rapidly and I'm not getting xruns because of it. You might want to try it if you dont want your cpu running at full power all the time. Or then you can bore yourself making your own governors. ;)

I think the switching of CPU frequencies causes xruns or issues with JACK. If you keep your CPU on a constant frequency JACK might not complain. Never tested this though.
Yeah ok. With my set of programs the frequency goes to max and stays there when I make music using the conservative governor. But you are right. It is wiser to use the performance governor with JACK. Though I would still recommend switching back to ondemand or conservative when not using JACK if you are on a laptop and use it for other things too.

I used to run it in performance all the time, but then I got a bit worried because it was so hot all the time. I dont think its very good for the hardware. Ofcourse it is because the laptop isn't very high quality and not a good design. Just thought I should mention this.
User avatar
autostatic
Established Member
Posts: 1994
Joined: Wed Dec 09, 2009 5:26 pm
Location: Beverwijk, The Netherlands
Has thanked: 32 times
Been thanked: 104 times
Contact:

Re: cpu frequency scaling

Post by autostatic »

Scary Hallo wrote:Does anybody figure out, how to set it permanently to 'performace' in Ubuntu 10.4?
System wide or on a per-user basis? System wide: disable the ondemand service. I use sysv-rc-conf to do this. Per user: I do this with a script that sets the governor to performance.
studio32

Re: cpu frequency scaling

Post by studio32 »

@autostatic, are you willing to post an example of such a script? thanks
User avatar
autostatic
Established Member
Posts: 1994
Joined: Wed Dec 09, 2009 5:26 pm
Location: Beverwijk, The Netherlands
Has thanked: 32 times
Been thanked: 104 times
Contact:

Re: cpu frequency scaling

Post by autostatic »

Sure, nothing special though, just a line like:

Code: Select all

sudo cpufreq-selector -g performance
That's all actually. SR's solution is much more elegant.
User avatar
Scary Hallo
Established Member
Posts: 280
Joined: Fri Oct 23, 2009 2:21 pm
Location: Germany / Pforzheim
Contact:

Re: cpu frequency scaling

Post by Scary Hallo »

That doesn't work for me. I put

Code: Select all

sudo cpufreq-selector -g performance
in my rc.local
I also tryed

Code: Select all

sudo cpufreq-set -g performance
and

Code: Select all

sudo /usr/bin/cpufreq-set -g performance
But in a few minutes it's back on 'ondemad'
User avatar
autostatic
Established Member
Posts: 1994
Joined: Wed Dec 09, 2009 5:26 pm
Location: Beverwijk, The Netherlands
Has thanked: 32 times
Been thanked: 104 times
Contact:

Re: cpu frequency scaling

Post by autostatic »

If you put those lines in rc.local then you don't need sudo. And maybe it might be better in your case to disable the ondemand service altogether since you're using rc.local to change the settings system-wide. And I've ran into that issue too that even though I had set my CPU's to performance they switched back to ondemand. I'll have to check again how I worked around that.
morko
Established Member
Posts: 45
Joined: Thu Mar 25, 2010 8:08 am
Location: Finland

Re: cpu frequency scaling

Post by morko »

AutoStatic wrote:If you put those lines in rc.local then you don't need sudo. And maybe it might be better in your case to disable the ondemand service altogether since you're using rc.local to change the settings system-wide. And I've ran into that issue too that even though I had set my CPU's to performance they switched back to ondemand. I'll have to check again how I worked around that.
Maybe there is cpufreq daemon running and it changes it back to what it is set in the cpufreq config?
User avatar
Scary Hallo
Established Member
Posts: 280
Joined: Fri Oct 23, 2009 2:21 pm
Location: Germany / Pforzheim
Contact:

Re: cpu frequency scaling

Post by Scary Hallo »

Maybe it has something to do with the 'ondemand'-script in /etc/init.d
User avatar
raboof
Established Member
Posts: 1855
Joined: Tue Apr 08, 2008 11:58 am
Location: Deventer, NL
Has thanked: 50 times
Been thanked: 74 times
Contact:

Re: cpu frequency scaling

Post by raboof »

Scary Hallo wrote:Maybe it has something to do with the 'ondemand'-script in /etc/init.d
Sounds likely. 'grep ondemand /etc/init.d/*' gave me /etc/init.d/cpufrequtils, which is where Debian (and I guess Ubuntu) store the default governor.

Reading the script, looks like the proper way to set the governor on ubuntu is creating a /etc/default/cpufrequtils and adding 'export GOVERNOR="performance"' to it.
User avatar
angelsguitar
Established Member
Posts: 145
Joined: Sat May 31, 2008 10:30 am
Location: Florida
Contact:

Re: cpu frequency scaling

Post by angelsguitar »

Hi guys!

Recently, I downloaded an Ubuntu 10.04 Minimal CD and installed a CLI, then just added the software I use (I'm using LXDE as Window Manager). After experimenting some xruns and running the Realtime Configuration script, I realized I had problems with cpu scaling too.

I installed the cpufreqd and cpufrequtils packages to be able to set cpu scaling on my system, since LXDE doesn't have any other way (a least that I know of), and directly editing the files in the /sys directory didn't work permanently - it would just switch to ondemand on every reboot.

Now, I believe I managed to change the cpuscaling setting in my system by editing the /etc/init.d/cpufrequtils and changing the "GOVERNOR" setting to "performance". However, the funny thing is that, when I run the realtime configuration script, it says that my system is running "ondemand":

Code: Select all

== GUI-enabled checks ==
Checking if you are root... no - good
Checking filesystem 'noatime' parameter... 2.6.33 kernel - good
(relatime is default since 2.6.30)
Checking CPU Governors... CPU 0: 'ondemand' CPU 1: 'ondemand'  - not good
Set CPU Governors to 'performance' with 'cpufreq-set -c <cpunr> -g performance'
See also: http://linuxmusicians.com/viewtopic.php?f=27&t=844
Checking swappiness... 10 - good
Checking for resource-intensive background processes... none found - good
Checking checking sysctl inotify max_user_watches... >= 524288 - good
Checking access to the high precision event timer... readable - good
Checking access to the real-time clock... readable - good
Checking whether you're in the 'audio' group... yes - good
Checking for multiple 'audio' groups... no - good
yes - good.
Checking the ability to prioritize processes with chrt... yes - good
== Other checks ==
Finding current kernel config... found /boot/config-2.6.33-6-rt
Checking for Ingo Molnar's Real-Time Preemption... found - good.
Checking for high-resolution timers... found - good.
Checking for 1000hz clock... found - good.
Checking for High Resolution Timers... found - good.
Checking filesystem types... ok.
ok.
** Set $SOUND_CARD_IRQ to the IRQ of your soundcard to enable more checks.
   Find your sound card's IRQ by looking at '/proc/interrupts' and lspci.
but when I run cpufreq-info, it says it's running at the maximum setting (previously, ondemand made my system run in 1600 MHz instead of the maximum 2.93):

Code: Select all

cpufrequtils 006: cpufreq-info (C) Dominik Brodowski 2004-2009
Report errors and bugs to cpufreq@vger.kernel.org, please.
analyzing CPU 0:
  driver: acpi-cpufreq
  CPUs which run at the same hardware frequency: 0
  CPUs which need to have their frequency coordinated by software: 0
  maximum transition latency: 160 us.
  hardware limits: 1.60 GHz - 2.93 GHz
  available frequency steps: 2.93 GHz, 2.13 GHz, 1.60 GHz
  available cpufreq governors: conservative, ondemand, userspace, powersave, performance
  current policy: frequency should be within 2.93 GHz and 2.93 GHz.
                  The governor "ondemand" may decide which speed to use
                  within this range.
  current CPU frequency is 2.93 GHz.
  cpufreq stats: 2.93 GHz:100.00%, 2.13 GHz:0.00%, 1.60 GHz:0.00%
analyzing CPU 1:
  driver: acpi-cpufreq
  CPUs which run at the same hardware frequency: 1
  CPUs which need to have their frequency coordinated by software: 1
  maximum transition latency: 160 us.
  hardware limits: 1.60 GHz - 2.93 GHz
  available frequency steps: 2.93 GHz, 2.13 GHz, 1.60 GHz
  available cpufreq governors: conservative, ondemand, userspace, powersave, performance
  current policy: frequency should be within 2.93 GHz and 2.93 GHz.
                  The governor "ondemand" may decide which speed to use
                  within this range.
  current CPU frequency is 2.93 GHz.
  cpufreq stats: 2.93 GHz:100.00%, 2.13 GHz:0.00%, 1.60 GHz:0.00%
Running "more /proc/cpuinfo | grep MHz" yields the following:

Code: Select all

cpu MHz		: 2933.000
cpu MHz		: 2933.000
Before editing the configuration files mentioned, it yielded "1600" on both cores.

The xruns are gone, so I believe the system is running in performance mode. Could it be a bug in the realtime configuration script? Maybe the cpufreq daemon is somehow overriding the system's default setting, which the script doesn't report.
Ángel A. Candelaria Colón
Guitar Professor
https://angelsguitar.com
User avatar
angelsguitar
Established Member
Posts: 145
Joined: Sat May 31, 2008 10:30 am
Location: Florida
Contact:

Re: cpu frequency scaling

Post by angelsguitar »

Well, after a little tweaking and experimentation, I found that by editing /etc/init.d/ondemand I can make the governor change permanent. I just opened the file and on this section

Code: Select all

for CPUFREQ in /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
	do
		[ -f $CPUFREQ ] || continue
		echo -n ondemand > $CPUFREQ
	done
I changed the part that says "ondemand" for "performance", so it now reads like this:

Code: Select all

for CPUFREQ in /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
	do
		[ -f $CPUFREQ ] || continue
		echo -n performance > $CPUFREQ
	done
I don't know if this is the best way to do it, but it works for me - now the system boots in performance mode everytime, and both the realtime configuration script and cpufreq-info report the system as running in performance mode. Seems that, using this method, neither cpufreqd nor cpufrequtils is needed to make the change permanent.
Ángel A. Candelaria Colón
Guitar Professor
https://angelsguitar.com
Post Reply