Debian performance tuning via dynamic CPU frequency scaling
Dynamic CPU frequency scaling (also known as CPU throttling) is a technique in computer architecture where a processor is run at a less-than-maximum frequency in order to conserve power. cpufrequtils is used to control the CPU frequency scaling deamon. Frequency scaling allows you to set the CPU frequency on-the-fly or specify an automatic governor.
To install cpufrequtils
1 2 |
sudo apt-get update sudo apt-get install cpufrequtils |
To set maximum performance:
1 |
sudo cpufreq-set -r -g performance |
or
1 |
sudo for i in $(ls /sys/devices/system/cpu/ | grep 'cpu[0-9]'); do echo performance> /sys/devices/system/cpu/${i}cpufreq/scaling_governor; done |
To test:
1 2 |
sudo apt-get install cpufreqd sudo cpufreqd-get -l |
Real example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
root@server:~# less /proc/cpuinfo | egrep 'model name|cpu MHz' model name : Intel(R) Xeon(R) CPU E31240 @ 3.30GHz cpu MHz : 1600.000 model name : Intel(R) Xeon(R) CPU E31240 @ 3.30GHz cpu MHz : 1600.000 model name : Intel(R) Xeon(R) CPU E31240 @ 3.30GHz cpu MHz : 1600.000 model name : Intel(R) Xeon(R) CPU E31240 @ 3.30GHz cpu MHz : 1600.000 root@server:~# cpufreq-set -r -g performance #-r for related (all) the cores root@server:~# less /proc/cpuinfo | egrep 'model name|cpu MHz' model name : Intel(R) Xeon(R) CPU E31240 @ 3.30GHz cpu MHz : 3301.000 model name : Intel(R) Xeon(R) CPU E31240 @ 3.30GHz cpu MHz : 3301.000 model name : Intel(R) Xeon(R) CPU E31240 @ 3.30GHz cpu MHz : 3301.000 model name : Intel(R) Xeon(R) CPU E31240 @ 3.30GHz cpu MHz : 3301.000 |
Migraiton process:
1 2 3 4 5 6 7 8 9 10 |
root@server:~# cpufreq-info | grep 'cpufreq stats:' cpufreq stats: 3.30 GHz:35.38%, 3.30 GHz:0.03%, 3.10 GHz:0.01%, 2.90 GHz:0.01%, 2.70 GHz:0.01%, 2.50 GHz:0.01%, 2.30 GHz:0.00%, 2.10 GHz:0.01%, 1.90 GHz:0.08%, 1.70 GHz:0.00%, 1.60 GHz:64.46% (95) cpufreq stats: 3.30 GHz:36.15%, 3.30 GHz:0.03%, 3.10 GHz:0.03%, 2.90 GHz:0.01%, 2.70 GHz:0.01%, 2.50 GHz:0.03%, 2.30 GHz:0.02%, 2.10 GHz:0.05%, 1.90 GHz:0.01%, 1.70 GHz:0.01%, 1.60 GHz:63.63% (151) cpufreq stats: 3.30 GHz:35.90%, 3.30 GHz:0.01%, 3.10 GHz:0.01%, 2.90 GHz:0.00%, 2.70 GHz:0.00%, 2.50 GHz:0.01%, 2.30 GHz:0.02%, 2.10 GHz:0.03%, 1.90 GHz:0.00%, 1.70 GHz:0.01%, 1.60 GHz:64.02% (98) cpufreq stats: 3.30 GHz:35.24%, 3.30 GHz:0.01%, 3.10 GHz:0.01%, 2.90 GHz:0.00%, 2.70 GHz:0.00%, 2.50 GHz:0.00%, 2.30 GHz:0.00%, 2.10 GHz:0.04%, 1.90 GHz:0.01%, 1.70 GHz:0.00%, 1.60 GHz:64.70% (45) root@server:~# cpufreq-info | grep 'cpufreq stats:' cpufreq stats: 3.30 GHz:36.40%, 3.30 GHz:0.03%, 3.10 GHz:0.01%, 2.90 GHz:0.01%, 2.70 GHz:0.01%, 2.50 GHz:0.01%, 2.30 GHz:0.00%, 2.10 GHz:0.01%, 1.90 GHz:0.08%, 1.70 GHz:0.00%, 1.60 GHz:63.44% (95) cpufreq stats: 3.30 GHz:37.16%, 3.30 GHz:0.03%, 3.10 GHz:0.03%, 2.90 GHz:0.01%, 2.70 GHz:0.01%, 2.50 GHz:0.03%, 2.30 GHz:0.02%, 2.10 GHz:0.05%, 1.90 GHz:0.01%, 1.70 GHz:0.01%, 1.60 GHz:62.63% (151) cpufreq stats: 3.30 GHz:36.91%, 3.30 GHz:0.01%, 3.10 GHz:0.01%, 2.90 GHz:0.00%, 2.70 GHz:0.00%, 2.50 GHz:0.01%, 2.30 GHz:0.02%, 2.10 GHz:0.03%, 1.90 GHz:0.00%, 1.70 GHz:0.01%, 1.60 GHz:63.00% (98) cpufreq stats: 3.30 GHz:36.27%, 3.30 GHz:0.01%, 3.10 GHz:0.01%, 2.90 GHz:0.00%, 2.70 GHz:0.00%, 2.50 GHz:0.00%, 2.30 GHz:0.00%, 2.10 GHz:0.04%, 1.90 GHz:0.01%, 1.70 GHz:0.00%, 1.60 GHz:63.67% (45) |