Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8202384

Introduce alternate jvm variant with speculative execution disabled



    • Bug
    • Resolution: Not an Issue
    • P2
    • tbd
    • 7, 8, 11
    • tools
    • None


      In order to allow for users not affected by problems with speculative execution to run a JVM at full speed, we need to ship two JVM libraries - one that is compiled with speculative execution enabled, and one that is compiled without. Enabled and disabled in the C++ compiler that builds the JVM, that is.

      Experiments were done with JDK 11 on Linux using the new gcc 7.3 with the three flags -mindirect-branch=thunk -mfunction-return=thunk -mindirect-branch-register. When the full JDK is compiled with these flags enabled there is an 18-29% performance regression in startup times. This is because during startup a lot of time is spent in the JVM, which is code compiled by gcc. Throughput benchmarks are largely unaffected since most of their time is spent in JIT compiled code. With a JDK where all native libraries except the JVM are compiled with gcc mitigations it is observed that all the startup regressions are gone.

      The recommendation from the Oracle JDK performance team is therefore to offer two versions of the JVM library, one safe and one fast, and to use a single safe version of all other libraries. To achieve this the Java launcher needs to have the ability to allow the user to choose which JVM to run. This is similar to the client/server model that we used to have.

      Speculative execution is enabled by default, so a single flag can be used to disable it if desired.

      Building the JDK with these options requires gcc 7.3 (linux) or VS 2017 (windows). Other platforms are not affected at this point.


        Issue Links



              erikj Erik Joelsson
              jwilhelm Jesper Wilhelmsson
              0 Vote for this issue
              14 Start watching this issue