Linux kernel is able to control every tiny bit of the hardware it operates. This time I am going to max out my server’s CPU performance by tuning the CPU to the performance mode.
I have been renting a dedicated server for a long time, on the server I have been hosting a few virtual servers to serve my needs. In order to bring up the performance a little bit, I decide to bring the CPU frequency in high ranges at all times.
The raw way is to put performance (should be defined in /sys/devices/system/cpu/cpu*/cpufreq/scaling_available_governors) to /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
Now if my server has 1 or 2 cores, I may just change the cpu0 and cpu1 values directly, but what if I have 32 cores or even more? Human errors will occur while scripting. We have command line tools to help us changing the governor instead, it is called cpupower.
All commands are run under root.
Install cpupower
On CentOS, cpupower is brought by kernel-tools package.
yum install kernel-tools -y
Turn on cpupower service
systemctl daemon-reload systemctl enable cpupower systemctl start cpupower
Now by your definition of the cpupower service, you may have already turned on performance mode, please check any of the scaling_governor file.
Make machine performant
cpupower frequency-set -g performance
You should be set. Check your CPU cores by watch -s 2 cat /proc/cpuinfo (control+c terminates watch)
Your CPU cores should be running at high frequency range at all times.