Which Java HotSpot JIT compiler is running?
Asked Answered
F

3

11

I would like to know if my no VM argument invocation of HotSpot Java is running with -client, -server, or tiered compilation options. When I supply no VM arguments, which one is chosen by default? Is there a way to output diagnostics about which JIT compiler is running?

Ferneferneau answered 11/2, 2013 at 18:34 Comment(0)
J
5

Assuming this is Hotspot:

-XshowSettings:vm

For example, on my Windows box I get output of:

VM settings:
    Max. Heap Size (Estimated): 1.77G
    Ergonomics Machine Class: client
    Using VM: Java HotSpot(TM) 64-Bit Server VM
Jackelinejackelyn answered 11/2, 2013 at 18:39 Comment(3)
Thanks Jon. I am running Hotspot on OS X, but for Java 1.6 & 1.7 that option is unrecognized, alas.Ferneferneau
@JulienChastang: That's odd - it's fine for me on both Windows and Linux. What does java -X show?Jackelinejackelyn
My bad. Actually on 1.6 it is unrecognized, but on 1.7 it gives me the sort of information you provide above. Curiously, when I supply the java -client -XshowSettings:vm it still claims to be Server. Charles Nutter (blog.headius.com/2009/01/my-favorite-hotspot-jvm-flags.html) seems to suggest that if you are on 64 bit, -server is the only option. It would be nice to get some clarity about this from Oracle.Ferneferneau
C
2

From the program that is run, you could query the java.vm.name property to differentiate between client and server mode. On hotspot it will contain "Server" if you have used that option (for example: Java HotSpot(TM) 64-Bit Server VM).

According to this page:

Tiered compilation is now the default mode for the server VM.

Note: it works now but is probably not the most future-proof approach.

Chouinard answered 11/2, 2013 at 18:39 Comment(0)
S
1

Slightly better method of determining which JIT compiler is in use.

On a Windows machine with 32-bit JDK8:

    $ java -version
    java version "1.8.0"
    Java(TM) SE Runtime Environment (build 1.8.0-b132)
    Java HotSpot(TM) Client VM (build 25.0-b70, mixed mode)

    $ java -XshowSettings -version 2>&1 | grep sun.management.compiler
        sun.management.compiler = HotSpot Client Compiler

    $ java -server -XshowSettings -version 2>&1 | grep sun.management.compiler
        sun.management.compiler = HotSpot Tiered Compilers

So the Client Compiler is the default with the Windows 32-bit JDK8 and the '-server' option gets you the 32-bit Tiered Compiler.

On a Windows machine with 64-bit JDK8:

    $ java -version
    java version "1.8.0"
    Java(TM) SE Runtime Environment (build 1.8.0-b132)
    Java HotSpot(TM) 64-Bit Server VM (build 25.0-b70, mixed mode)

    $ java -XshowSettings -version 2>&1 | grep sun.management.compiler
        sun.management.compiler = HotSpot 64-Bit Tiered Compilers

So the Tiered Compiler is the default with the Windows 64-bit JDK8. Oracle does not provide a 64-bit Client VM.

Sooth answered 1/5, 2014 at 20:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.