Skip to main content

Understanding -XX:+PrintCompilation Output in Java

Understanding -XX:+PrintCompilation Output in Java

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

Popular posts from this blog

Understanding C1 and C2 Compilers in Java

Understanding C1 and C2 Compilers in Java Understanding C1 and C2 Compilers in Java In Java, the Just-In-Time (JIT) compiler is a part of the Java Virtual Machine (JVM) that improves the performance of Java applications by compiling bytecode into native machine code at runtime. The JIT compiler includes two different compilers, known as the C1 and C2 compilers, each with distinct optimization strategies and purposes. C1 Compiler (Client Compiler) The C1 compiler, also known as the client compiler, is designed for fast startup times and lower memory consumption. It performs lighter and quicker optimizations, which makes it suitable for applications that require quick startup and responsiveness. Key characteristics of the C1 compiler include: Quick Compilation: Prioritizes fast compilation times over deep optimizations. Low Overhead: Consumes less memory and resources during compilation. Profile-Guided Optimization: Ca...

What is L1, L2 and L3 Support Engineering

In this blog article, I'm going to explain about the Software support engineering role with my experience. I was a Level 2 and 3 support Engineer during my career. L1 - Level 1 L2 - Level 2 L3 - Level 3 Ticket - Incident L1 support includes interacting with customers, understand their issue and create tickets against it. The ticket then routed to the relevant L2 support ( Integration support, Server & Storage support, etc ...). L1 support Engineers have basic knowledge of product/service and skill to troubleshoot a very basic issue like password reset, software installation/uninstallation/reinstallation. L2 support manages the tickets which routed to them by L1( L2 support also can create tickets against any issue notice by them). They have more knowledge, more experience in solving related complex issues and can guide/help L1 support folks job in troubleshooting. If the solution not provided at this level then escalate to the L3. L3 is ...