There's a GUI application that allows you to set minimum and maximum CPU speeds, and change the CPU governor. It works for both Intel and AMD CPUs:
sudo apt install cpupower-gui
The types of CPU governors:
performance: Run the CPU at maximum frequency, obtained from /sys/devices/system/cpu/cpuX/cpufreq/scaling_max
.
powersave: Run the CPU at the minimum frequency, obtained from /sys/devices/system/cpu/cpuX/cpufreq/scaling_min_freq
.
userspace: Run the CPU at user specified frequencies, configurable via /sys/devices/system/cpu/cpuX/cpufreq/scaling_setspeed
. Some systems don't support this, so it defaults to the ondemand governor if the governor is set to this (my AMD Ryzen CPU, for one example).
ondemand: The default governor. Scales the frequency dynamically according to current load. Jumps to the highest frequency and then backs off as the idle time increases.
conservative: Scales the frequency dynamically according to current load. Scales the frequency more gradually than ondemand.
schedutil: Scheduler-driven CPU frequency selection.
You can alter the load at which the CPU switches to a higher frequency... for instance, when using the ondemand CPU governor (the default governor), I noticed that it's rather frenetic in switching to higher frequencies, even when the computer isn't being used and the CPU is idle.
The default value for my /sys/devices/system/cpu/cpufreq/ondemand/up_threshold
file is 95. I changed it to 99.
Start cpupower-gui and set the governor for all CPUs to ondemand.
sudo su
echo -n 99 > /sys/devices/system/cpu/cpufreq/ondemand/up_threshold
Or, you can do the same for the conservative governor, which has a default value for /sys/devices/system/cpu/cpufreq/conservative/up_threshold
of 80, and for /sys/devices/system/cpu/cpufreq/conservative/down_threshold
of 20:
Start cpupower-gui and set the governor for all CPUs to conservative.
sudo su
echo -n 99 > /sys/devices/system/cpu/cpufreq/conservative/up_threshold
echo -n 95 > /sys/devices/system/cpu/cpufreq/conservative/down_threshold
That's what I'm using now. The CPU stays at or near its lowest frequency when the computer isn't being used, but scales up in frequency when it is being used.
Now, the above doesn't stick between reboots... but we don't have to create a service that runs at boot to set the CPU governor each time...
there's already a service we can install that'll do that.
sudo apt install cpufrequtils
echo 'GOVERNOR="conservative"' | sudo tee /etc/default/cpufrequtils
sudo systemctl disable ondemand
Why? Because as the computer boots, it uses the performance CPU governor, waits 1 minute, then switches to the ondemand governor. If it cannot switch to the ondemand governor, it attempts to change to the Schedutil governor, unless something sets it to something else... that something is cpufrequtils.
"But the
echo -n 99 > /sys/devices/system/cpu/cpufreq/conservative/up_threshold
echo -n 95 > /sys/devices/system/cpu/cpufreq/conservative/down_threshold
settings aren't maintained between reboots!", some quick-eyed individual will note.
Yes, you're right. For that, the simplest solution is to set the relevant settings at startup.
Zorin menu
> System Tools
> Startup Applications
Add the following:
Name: Set CPU down_threshold
Command: sudo sh -c "echo 95 > /sys/devices/system/cpu/cpufreq/conservative/down_threshold"
Name: Set CPU freq_step
Command: sudo sh -c "echo 1 > /sys/devices/system/cpu/cpufreq/conservative/freq_step"
Name: Set CPU ignore_nice_load
Command: sudo sh -c "echo 1 > /sys/devices/system/cpu/cpufreq/conservative/ignore_nice_load"
Name: Set CPU up_threshold
Command: sudo sh -c "echo 99 > /sys/devices/system/cpu/cpufreq/conservative/up_threshold"