In this blog, we’ll examine how CPU governor performance affects MySQL.
It’s been a while since we looked into CPU governors and with the new Intel CPUs and new Linux distros, I wanted to check how CPU governors affect MySQL performance.
Before jumping to results, let’s review what drivers manage CPU frequency. Traditionally, the default driver was “acpi-cpufreq”, but for the recent Intel CPUs and new Linux kernel it was changed to “intel_pstate”.
To check what driver is being used, run the command cpupower frequency-info .
|
1 |
cpupower frequency-info<br>analyzing CPU 0:<br>driver: acpi-cpufreq<br>CPUs which run at the same hardware frequency: 0<br>CPUs which need to have their frequency coordinated by software: 0<br>maximum transition latency: 10.0 us.<br>hardware limits: 1.20 GHz - 2.00 GHz<br>available frequency steps: 2.00 GHz, 2.00 GHz, 1.90 GHz, 1.80 GHz, 1.70 GHz, 1.60 GHz, 1.50 GHz, 1.40 GHz, 1.30 GHz, 1.20 GHz<br>available cpufreq governors: conservative, ondemand, userspace, powersave, performance<br>current policy: frequency should be within 1.20 GHz and 2.00 GHz.<br>The governor "ondemand" may decide which speed to use<br>within this range.<br>current CPU frequency is 1.20 GHz (asserted by call to hardware).<br>cpufreq stats: 2.00 GHz:29.48%, 2.00 GHz:0.00%, 1.90 GHz:0.00%, 1.80 GHz:0.00%, 1.70 GHz:0.00%, 1.60 GHz:0.00%, 1.50 GHz:0.00%, 1.40 GHz:0.00%, 1.30 GHz:0.37%, 1.20 GHz:70.15% (7)<br>boost state support:<br>Supported: yes<br>Active: yes<br> |
In this case, we can see that the driver is “acpi-cpufreq”, and the governor is “ondemand”.
On my server (running Ubuntu 16.04, running “Intel(R) Xeon(R) CPU E5-2683 v3 @ 2.00GHz” CPUs), I get following output by default settings:
|
1 |
analyzing CPU 0:<br>driver: intel_pstate<br>CPUs which run at the same hardware frequency: 0<br>CPUs which need to have their frequency coordinated by software: 0<br>maximum transition latency: 0.97 ms.<br>hardware limits: 1.20 GHz - 3.00 GHz<br>available cpufreq governors: performance, powersave<br>current policy: frequency should be within 1.20 GHz and 3.00 GHz.<br>The governor "performance" may decide which speed to use<br>within this range.<br>current CPU frequency is 1.50 GHz (asserted by call to hardware).<br>boost state support:<br>Supported: yes<br>Active: yes<br> |
So, it’s interesting to see that “intel_pstate” with the “performance” governor is chosen by default, and the CPU frequency range is 1.20GHz to 3.00GHz (even though the CPU specification is 2.ooGHz). If we check CPU specification page, it says that 2.00GHz is the “base frequency” and “3.00GHz” is the “Max Turbo” frequency.
In contrast to “intel_pstate”, “acpi-cpufreq” says “frequency should be within 1.20 GHz and 2.00 GHz.”
Also, “intel_pstate” only supports “performance” and “powersave” governors, while “acpi-cpufreq” has a wider range. For this blog, I only tested “ondemand” and “performance”.
Switching between CPU drivers is not easy, as it requires a server reboot — you need to pass a parameter to the kernel startup line. In Ubuntu, you can do this in /etc/default/grub by changing GRUB_CMDLINE_LINUX_DEFAULT to GRUB_CMDLINE_LINUX_DEFAULT="intel_pstate=disable", which will disable intel_pstate and will load acpi-cpufreq.
Is there a real difference in performance between different CPU drivers and CPU governors? To check , I took a sysbench OLTP read-only workload over a 10Gb network, where the data fits into memory (so it is CPU-burning workload).
The results are as follows. This is a chart for absolute throughput:
And to better understand relative performance, here is a chart on how other governors perform compared to “intel-pstate” with the performance governor. In this case, I showed relative performance to “PSTATE performance”, which equals “1”. In the chart, the orange bar is “PSTATE powersave” and shows the relative difference between “PSTATE powersave” and “PSTATE performance” (=1):
Here are the takeaways I see:
Resources
RELATED POSTS