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

How to use WSO2 Class Mediator in WSO2 ESB

The  Class Mediator  creates an instance of a custom-specified class and sets it as a mediator. If any properties are specified, the corresponding setter methods are invoked once on the class during initialization. Use the Class mediator for user-specific, custom developments only when there is no built-in mediator that already provides the required functionality.  The syntax of Class Mediator in ESB < class   name= "class-name" >     <property name= "string"   value= "literal" >     </property> </ class > Creating a Class Mediator lets use the Eclipse  WSO2 Developer Studio Create a New  Mediator project by selecting File --> New --> project --> Mediator Project Now you have class mediator by extending the AbstractMediator class. Then you need to implement the mediate methods Sample class mediator implementation is as follows. package lk.harshana; import org.apache.synapse.Mess

One to Many Mapping using Spring boot

In this blog, I will explain how to use one-to-many mapping in Spring boot Application What you need? JAVA MySql Eclipse IDE ( whatever you like IDE, I'm using Eclipse for this example) Maven ( you can use the Gradle as well) Initial Plan I will create a spring boot application project using the  Spring Initializer  web tool and import the project as a maven project. after configuring the all necessary setting, I will code for one-to-many mapping. Below diagram is the database model diagram which we going to install using the spring boot application. Let's Start to Code. You need to configure the application.properties file for database connections. add the following content to the src/main/resources/application.properties spring.datasource.url=jdbc:mysql://localhost:3306/learning spring.datasource.username=root spring.datasource.password=root spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5InnoDBDialect spring.jpa.hibernate

When To Use Indexes In MySQL

When deciding when and how to create an index in your MySQL database, it's important to consider how the data is being used. Let's say you have a database of  students . We will create it like this: CREATE TABLE `students` ( `id` int ( 11 ) NOT NULL AUTO_INCREMENT , `first_name` varchar ( 255 ) DEFAULT NULL , `last_name` varchar ( 255 ) DEFAULT NULL , `class` varchar ( 255 ) DEFAULT NULL , PRIMARY KEY ( `id` ) ) ENGINE = InnoDB Indexes are best used on columns that are frequently used in where clauses, and in any kind of sorting, such as "order by". You should also pay attention to whether or not this information will change frequently, because it will slow down your updates and inserts. Since you wont frequently be adding students, you don't have to worry about the inserts Let's say that you will be looking up the students with a web interface and the end user will be typing in the students name to find them, since r