Understanding -XX:+PrintCompilation
Output in Java
The -XX:+PrintCompilation
flag in the Java Virtual Machine (JVM) prints information about the methods being compiled by the Just-In-Time (JIT) compiler. When you enable this flag, the JVM will output a log of compilation events to the standard output. Each line of the output provides information about a specific method being compiled. Here, I'll explain the meaning of the different columns and markers, specifically focusing on the n
, s
, and %
markers as seen in your example.
Explanation of Output Columns and Markers
Here's a breakdown of what each column and marker means:
- Timestamp: The time (in milliseconds) since the JVM started when the compilation event occurred.
- Compilation ID: A unique identifier for each compilation task within the JVM's lifecycle.
- Optimization Level: The level of optimization applied (e.g.,
1
,3
,4
). - Method Name and Details: The fully qualified name of the method being compiled, along with the size of the method in bytes.
- Marker: Indicates special conditions or additional information about the compilation.
Common Markers
n
: Indicates that the method is a native method.s
: Indicates that the method is synchronized.%
: Indicates that the method has been compiled at a higher optimization level.
Detailed Breakdown of Example Output
Let's go through a portion of your example output line by line:
44 1 3 java.lang.String::charAt (29 bytes)
46 2 n 0 java.lang.System::arraycopy (native) (static)
48 3 3 java.lang.String::hashCode (55 bytes)
48 4 3 java.lang.String::indexOf (70 bytes)
49 5 3 java.lang.String::equals (81 bytes)
49 7 3 java.lang.Object:: (1 bytes)
49 6 3 java.lang.String::length (6 bytes)
51 8 3 java.lang.AbstractStringBuilder::ensureCapacityInternal (27 bytes)
52 9 3 java.lang.CharacterData::of (120 bytes)
53 14 3 java.lang.AbstractStringBuilder::append (29 bytes)
53 10 3 java.lang.CharacterDataLatin1::getProperties (11 bytes)
55 19 4 java.lang.String::charAt (29 bytes)
57 15 3 java.lang.StringBuilder::append (8 bytes)
58 1 3 java.lang.String::charAt (29 bytes) made not entrant
59 26 1 java.lang.Object:: (1 bytes)
59 7 3 java.lang.Object:: (1 bytes) made not entrant
59 22 3 PrimeNumbers::isPrime (35 bytes)
60 25 3 java.lang.Integer:: (10 bytes)
60 29 % 4 PrimeNumbers::isPrime @ 2 (35 bytes)
Explanation of Specific Lines
Line 1:
44 1 3 java.lang.String::charAt (29 bytes)
- 44: Timestamp in milliseconds since JVM start.
- 1: Compilation ID.
- 3: Optimization level.
- java.lang.String::charAt (29 bytes): Method name and size.
Line 2:
46 2 n 0 java.lang.System::arraycopy (native) (static)
- 46: Timestamp in milliseconds since JVM start.
- 2: Compilation ID.
- n 0: Native method compilation.
- java.lang.System::arraycopy (native): Method name, indicating it's a native method.
- (static): Indicates that the method is static.
Line 3:
48 3 3 java.lang.String::hashCode (55 bytes)
- 48: Timestamp in milliseconds since JVM start.
- 3: Compilation ID.
- Similar to Line 1, but for the
hashCode
method.
Line 16:
60 29 % 4 PrimeNumbers::isPrime @ 2 (35 bytes)
- 60: Timestamp in milliseconds since JVM start.
- 29: Compilation ID.
- % 4: Indicates high-level optimization.
- PrimeNumbers::isPrime @ 2 (35 bytes): Method name and size, compiled at high optimization level.
Not Entrant Methods
Not Entrant: Indicates that the method is no longer considered "hot" and is de-optimized, potentially to be recompiled if it becomes hot again.
58 1 3 java.lang.String::charAt (29 bytes) made not entrant
59 7 3 java.lang.Object:: (1 bytes) made not entrant
Summary of Compilation Markers
n
Marker: Indicates native methods.s
Marker: Indicates synchronized methods.%
Marker: Indicates methods compiled with high-level optimization.
This detailed breakdown should help you understand the output of the -XX:+PrintCompilation
flag and the significance of the n
, s
, and %
markers in the context of JIT compilation in the JVM.
Comments
Post a Comment