CPU Tweaks


Back to the homepage


Tweaking your CPU can be useful (plus it's a lot of fun for us nerds). Below, you'll learn a couple of ways to do that.

Contents of this page:


How to toggle the performance mode of your CPU

1. There's a nifty tool for toggling the performance mode of your CPU. This is how to install and use it:

a. Launch a terminal window.
(You can launch a terminal window like this: *Click*)

b. Copy/paste the following command line into the terminal:

sudo apt-get install cpupower-gui

Press Enter. Type your password when prompted. In Ubuntu this remains entirely invisible, not even dots will show when you type it, that's normal. In Mint this has changed: you'll see asterisks when you type. Press Enter again.

c. Then launch cpupower-gui from the menu and tweak to your heart's delight. It lets you set the scaling governor either individually for each CPU core (why?), or for all of them at once (which is of course what you want).

In Linux Mint 21.x and Ubuntu 22.04 the default setting is schedutil, which is the optimal choice for most users.

To check what your CPU cores are currently set to, utilize this terminal command (copy/paste it into the terminal and press Enter):

cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor

Limiting CPU usage for a particular application

2. It's possible to limit the CPU usage for a particular application, by means of taskset or cpulimit. Below, I'll describe both methods.

Setting a CPU limit with taskset

2.1. The terminal application taskset should be installed by default. It can be used when your CPU has more than one core, which is customary in modern computers.

With taskset you can determine which CPU core(s) a specified application may use, thus leaving the other CPU cores free to do other tasks. This might come in handy when your computer is running a big intensive background job.

Running taskset with the parameter -c allows you to set the CPU cores by number. Because taskset is a hard-core nerdy terminal application, it starts counting at 0 instead of 1 (something that nerds absolutely love), so for taskset a CPU with eight cores has cores 0, 1, 2, 3, 4, 5, 6, 7.

Some examples make things easier. Let's suppose that you want Timeshift to make a snapshot of your system. But in the background, so in the meanwhile you'll have enough computing power to do other things. You can then launch Timeshift with a restriction to use only the first core of your eight-core CPU, like this:

taskset -c 0 timeshift

Only the first three CPU cores:

taskset -c 0,1,2 timeshift

Only the middle two CPU cores (yes, I'm pleasing my inner nerd here!)

taskset -c 3,4 timeshift

You can also specify a range, for example in order to use only the last four cores:

taskset -c 4-7 timeshift

Setting a CPU limit with cpulimit

2.2. The terminal application cpulimit is not installed by default, so first install it:

sudo apt-get install cpulimit

With cpulimit you can determine the maximum percentage that an application may use of your CPU. If your CPU has only one core, the maximum percentage is 100. But if your CPU has four cores, then the maximum percentage is 400.

And it becomes even more complicated when your CPU has more than one thread per core: for a CPU with four cores and eight threads, the maximum percentage becomes 800.

An example makes things easier. Let's suppose that you want Timeshift to make a snapshot of your system. But in the background, so in the meanwhile you'll have enough computing power to do other things. You can then launch Timeshift with a restriction to use only 25 % of your two-core single-thread CPU, like this:

cpulimit -e timeshift -l 50

(50, because the CPU in the example has two single-thread cores, which means that cpulimit counts up to 200 %, so 50 is the true 25 % here)

To disable cpulimit:

pkill cpulimit


To the content of this website applies a Creative Commons license.

Back to the home page

Disclaimer