In this blog post, we’ll look at the performance hit from the Spectre bug fix on Ubuntu.
Recently we measured the performance penalty from the Meltdown fix on Ubuntu servers. It turned out to be negligible.
Today, Ubuntu made a Spectre bug fix on Ubuntu available, shipped in kernel 4.4.0-112. As with the Meltdown fix, we measured the effect of this update. Unfortunately, we observed a major performance penalty on MySQL workloads with this new kernel.
Our benchmark used the following:
System:
With the fix, the Spectre and Meltdown mitigation detection tool v0.27 reports following:
|
1 |
Checking for vulnerabilities against live running kernel Linux 4.4.0-112-generic #135-Ubuntu SMP Fri Jan 19 11:48:36 UTC 2018 x86_64<br><br>CVE-2017-5753 [bounds check bypass] aka 'Spectre Variant 1'<br>* Checking count of LFENCE opcodes in kernel: YES <br>> STATUS: NOT VULNERABLE (115 opcodes found, which is >= 70, heuristic to be improved when official patches become available)<br><br>CVE-2017-5715 [branch target injection] aka 'Spectre Variant 2'<br>* Mitigation 1<br>* Hardware (CPU microcode) support for mitigation: YES <br>* Kernel support for IBRS: YES <br>* IBRS enabled for Kernel space: YES <br>* IBRS enabled for User space: NO <br>* Mitigation 2<br>* Kernel compiled with retpoline option: NO <br>* Kernel compiled with a retpoline-aware compiler: NO <br>> STATUS: NOT VULNERABLE (IBRS mitigates the vulnerability)<br><br>CVE-2017-5754 [rogue data cache load] aka 'Meltdown' aka 'Variant 3'<br>* Kernel supports Page Table Isolation (PTI): YES <br>* PTI enabled and active: YES <br>> STATUS: NOT VULNERABLE (PTI mitigates the vulnerability)<br> |
Workload:
Server:
Sysbench script:
The results are in transactions per sec (more is better).
Connection via TCP
| bp | workload | threads | tps no-fix | tps fix | ratio no-fix/fix |
|---|---|---|---|---|---|
| 100 | oltp_read_only | 1 | 810.76 | 655.34 | 1.24 |
| 100 | oltp_read_only | 2 | 1589.66 | 1277.02 | 1.24 |
| 100 | oltp_read_only | 8 | 6233.69 | 5018.11 | 1.24 |
| 100 | oltp_read_only | 16 | 11253.28 | 9477.18 | 1.19 |
| 100 | oltp_read_only | 64 | 22702.29 | 18564.30 | 1.22 |
| 100 | oltp_read_only | 128 | 22281.22 | 18357.06 | 1.21 |
| 100 | oltp_point_select | 1 | 16095.32 | 12380.20 | 1.30 |
| 100 | oltp_point_select | 2 | 32665.97 | 24907.84 | 1.31 |
| 100 | oltp_point_select | 8 | 132480.34 | 101787.44 | 1.30 |
| 100 | oltp_point_select | 16 | 236832.94 | 189087.10 | 1.25 |
| 100 | oltp_point_select | 64 | 498322.41 | 415631.91 | 1.20 |
| 100 | oltp_point_select | 128 | 496661.65 | 414495.64 | 1.20 |
Connection via TCP
| bp | workload | threads | tps no-fix | tps fix | ratio no-fix/fix |
|---|---|---|---|---|---|
| 50 | oltp_read_only | 1 | 683.09 | 595.63 | 1.15 |
| 50 | oltp_read_only | 2 | 1390.70 | 1143.30 | 1.22 |
| 50 | oltp_read_only | 8 | 5262.02 | 4493.87 | 1.17 |
| 50 | oltp_read_only | 16 | 9842.04 | 8242.02 | 1.19 |
| 50 | oltp_read_only | 64 | 21021.20 | 17644.76 | 1.19 |
| 50 | oltp_read_only | 128 | 21526.21 | 17932.34 | 1.20 |
| 50 | oltp_point_select | 1 | 14535.73 | 11758.57 | 1.24 |
| 50 | oltp_point_select | 2 | 28721.43 | 23277.60 | 1.23 |
| 50 | oltp_point_select | 8 | 108422.96 | 90189.94 | 1.20 |
| 50 | oltp_point_select | 16 | 203876.31 | 167382.92 | 1.22 |
| 50 | oltp_point_select | 64 | 447757.48 | 376506.97 | 1.19 |
| 50 | oltp_point_select | 128 | 473894.73 | 384301.33 | 1.23 |
connection via TCP
| bp | workload | threads | tps no-fix | tps fix | ratio no-fix/fix |
|---|---|---|---|---|---|
| 25 | oltp_read_only | 1 | 542.09 | 470.88 | 1.15 |
| 25 | oltp_read_only | 2 | 1074.54 | 931.02 | 1.15 |
| 25 | oltp_read_only | 8 | 4169.10 | 3621.79 | 1.15 |
| 25 | oltp_read_only | 16 | 7626.30 | 6716.29 | 1.14 |
| 25 | oltp_read_only | 64 | 18206.18 | 15702.90 | 1.16 |
| 25 | oltp_read_only | 128 | 20224.22 | 16966.13 | 1.19 |
| 25 | oltp_point_select | 1 | 11107.73 | 9294.73 | 1.20 |
| 25 | oltp_point_select | 2 | 22486.65 | 18526.84 | 1.21 |
| 25 | oltp_point_select | 8 | 86385.70 | 73226.44 | 1.18 |
| 25 | oltp_point_select | 16 | 161409.65 | 135689.48 | 1.19 |
| 25 | oltp_point_select | 64 | 370809.49 | 320848.79 | 1.16 |
| 25 | oltp_point_select | 128 | 433324.54 | 358947.61 | 1.21 |
We can see that in CPU-bound workloads the overhead is 20-25%, reaching up to 30% in point select queries. In IO-bound (25G buffer pool) workloads, the observed overhead is 15-20%.
This is a major performance hit, and you should consider it carefully before upgrading to the new kernel.
One hope that is retpoline kernels will have much less impact.