How CPU Governor Performance Affects MySQL
How CPU Governor Performance Affects MySQL
This article looks at how CPU governors and the new Intel CPUs and Linux distros affect MySQL performance.
Join the DZone community and get the full member experience.Join For Free
Container Monitoring and Management eBook: Read about the new realities of containerization.
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 .
cpupower frequency-info analyzing CPU0: driver:acpi-cpufreq CPUs which run atthe same hardware frequency:0 CPUs which need tohave their frequency coordinated by software:0 maximum transition latency:10.0us. hardware limits:1.20GHz-2.00GHz available frequency steps:2.00GHz,2.00GHz,1.90GHz,1.80GHz,1.70GHz,1.60GHz,1.50GHz,1.40GHz,1.30GHz,1.20GHz available cpufreq governors:conservative,ondemand,userspace,powersave,performance current policy:frequency should be within1.20GHz and2.00GHz. The governor"ondemand"may decide which speed touse within thisrange. current CPU frequency is1.20GHz(asserted by call tohardware). cpufreq stats:2.00GHz:29.48%,2.00GHz:0.00%,1.90GHz:0.00%,1.80GHz:0.00%,1.70GHz:0.00%,1.60GHz:0.00%,1.50GHz:0.00%,1.40GHz:0.00%,1.30GHz:0.37%,1.20GHz:70.15%(7) boost state support: Supported:yes Active:yes
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:
analyzing CPU0: driver:intel_pstate CPUs which run atthe same hardware frequency:0 CPUs which need tohave their frequency coordinated by software:0 maximum transition latency:0.97ms. hardware limits:1.20GHz-3.00GHz available cpufreq governors:performance,powersave current policy:frequency should be within1.20GHz and3.00GHz. The governor"performance"may decide which speed touse within thisrange. current CPU frequency is1.50GHz(asserted by call tohardware). boost state support: Supported:yes Active:yes
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:
- The combination of CPU driver and CPU governors still affect performance
- ACPI ondemand might be not the best choice to achieve the best throughput
- Intel_pstate “powersave” is slower on a fewer number of threads (I guess the Linux scheduler assign execution to “sleeping” CPU cores)
- Both ACPI and Intel_pstate “performance” governor shows the best (and practically identical) performance
- My Ubuntu 16.04 starts with “intel_pstate” + “performance” governor by default, but you still may want to check what the settings are in your case (and change to “performance” if it is not set).
Published at DZone with permission of Vadim Tkachenko , DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.