Mitigration of jump conditional code wanted to avoid performance loss on Intel C...
source link: https://github.com/oracle/graal/issues/1829
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upNew issue
Mitigation of Jump Conditional Code (JCC) Erratum wanted to avoid performance loss on Intel CPUs #1829
Closed
plokhotnyuk opened this issue on 14 Nov 2019 · 18 comments
Comments
While largely overlooked due to the new TAA vulnerability and other security related issues, the new microcode from Intel includes a fix for the Jump Conditional Code (JCC) Erratum which carries a significant performance penalty: On the latest version of microcode slow and inefficient code is almost not affected, while for highly optimized with a lot of branching in hot loops throughput slowdown is up to 50% compared to results on the previous version of microcode. Previous:
Current:
Microcode updates for Linux (binaries and release notes): Bellow are comparisons of results for the same benchmarks when running on different versions of microcode: |
changed the title
Mitigration of jump conditional code wanted to avoid performance loss
Mitigration of jump conditional code wanted to avoid performance loss on Intel CPUs
Thanks for the report @plokhotnyuk . We will look into this but the window for 19.3 is pretty much closed for a change this size. That said, we will look into implementing something like the |
@dougxc @mur47x111 In the issue description I've added links to Intel CPU microcode updates (for Linux) and links for benchmarks comparison on different versions of microcode. I'm waiting 19.3 release with impatience and going to update comparison if I will find how to rollback to the previous version of microcode. BTW, new versions of microcode were released after 12/11/2019. ICYMI: A series of patches with code for a new -mbranches-within-32B-boundaries compiler option which "aligns conditional jump, fused conditional jump and unconditional jump within 32-byte boundary" has been proposed on the binutils mailing list. The problem introduced by JCC Erratum is hard to fix clearly and forcing everyone to pay a price in terms of runtime performance and codesize. In any case, please, also consider reordering of floating nodes, using of branch-less tricks with |
Given the short window for 19.3, we won't be able to include such fix in the 19.3 release. I have a nop-based prototype, and will convert it into a prefix-based solution and push into the next update release. |
@mur47x111 great work! Could you please share a branch with your prototype? |
Let me polish it first. Still many //TODO ;) |
IFYK: The initial patch landing in LLVM 10 llvm/llvm-project@14fc20c |
This is more complicated than I thought initially.. anyway, with 07ae939 and de73dbb we are now able to enable the jcc paddings. You only need to pass -Dgraal.UseBranchesWithin32ByteBoundary=true while running the application. When http://cr.openjdk.java.net/~eosterlund/8234160/webrev.01/ is merged, I will then set this option accordingly. @plokhotnyuk would you please give it a try and report if the patch helps addressing the regression? |
@mur47x111 Great work, Yudi! Just tried a couple of benchmarks on my laptop with Intel Core i7 and the latest version of microcode. graalvm-libgraal-java8-20.0.0 with -Dgraal.UseBranchesWithin32ByteBoundary=false
graalvm-libgraal-java8-20.0.0 with -Dgraal.UseBranchesWithin32ByteBoundary=true
|
BTW, does this flag align only branches? What about jumps, calls, and returns? Will be they aligned with this option turned on? |
@mur47x111 You've made Intel CPUs great again! Here is a comparison of results for the latest version of benchmarks on GraalVM CE Java8 20.0.0-dev with the |
@mur47x111 @dougxc I had built |
@mur47x111 do you have some insight as to what the cost of building libgraal with this option enabled will cost in terms of performance of libgraal on platforms that are not subject to the JCC erratum? |
changed the title
Mitigration of Jump Conditional Code (JCC) Erratum wanted to avoid performance loss on Intel CPUs
Mitigation of Jump Conditional Code (JCC) Erratum wanted to avoid performance loss on Intel CPUs
@mur47x111 I see that HotSpot C2 mitigations for jcc erratum are merged to the JDK master. Will you reuse their approach of turning on a branch alignment by default for affected CPUs? |
Closing as resolved... Works fine in early access builds of OpenJDK 15 too! |
Sorry for not replying earlier. With the new JVMCI https://github.com/graalvm/labs-openjdk-11/releases/tag/jvmci-20.1-b01 and 6fe6878 we are now able to turn on the branch alignment by default on affected CPUs. Latest JDK should contain the necessary patch as well. |
None yet
No milestone
Successfully merging a pull request may close this issue.
None yet
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK