Profile Image
vishnupriya

What is JVM startup parameter: -XX:+PrintInlining?

What is JVM startup parameter: -XX:+PrintInlining? Have you used this JVM arguement before? What are the pros & cons of using this Java argument? Can you share your perspective/experience in using this JVM argument?

  • jvmargument

  • xx-printinlining

  • x-printinlining

  • JVM startup parameter

Please Sign In or to post your comment or answer

Profile Image

Pavel Khodakovsky

Usage:

 

The option “-XX:+PrintInlining” allows you to enable printing the decisions of inlining optimizations made by the JVM.

 

Since:

 

Starting from JDK 6.

 

Examples:

 

This will instruct JVM to enable printing inlining optimizations:

 

-XX:+PrintInlining

 

Description:

 

Inlining is a way of optimizing the code by the compiler where it determines that a function should be replaced with its bodies. This optimization is performed by Just-In-Time (JIT) compiler which is a component of the JVM. The javac can only generate a bytecode of the classes and gives the rest to JIT to do the optimization. JIT compiler can’t inline every function which would take time and generate a massive binary, the JIT compiler only inlines the hot functions. To know which function is hot, JVM count the number of times the function has been called and how many loop has it executed. Thus, the argument “PrintInlining” comes in handy which enables the JVM to print of inlining decisions. This lets you to see which methods are getting inlined.

 

By default, this option is disabled and inlining information isn’t printed. The “-XX:+PrintInlining” option has to be used together with the “-XX:+UnlockDiagnosticVMOptions” option that unlocks diagnostic JVM options.

 

Example:

 

Let us create a simple class that do a simple mathematical operation:

 

Public class DataCounter {

 

    private int counter = 0;

 

    private int max;

 

   public DataCounter(int max) {

 

               this.max = max;

 

   }

 

    public int countData() {

 

               for (int i = 0; i < max; i++) {

 

                              counter += 1;

 

               }

 

return counter;

 

    }

 

}

 

After that, we can create a function which will initiate the class and call the function countData

 

public static long countData(int max) {

 

    return new DataCounter(max).countData();

 

}

 

Finally, we will call the last method in a loop

 

for (int i = 1; i < 100; i++) {

 

    countData(i);

 

}

 

If we ran the application with just 100 iterations, we won’t find the function countData

But if we ran it above the threshold 10,000, we notice that the function is displayed and inlined

 

Default Value:

 

By default, this option is disabled.

 

Arguments related:

 

UnlockDiagnosticVMOptions, Inline

 

Related Posts:

 

Got something else on mind? Post Your Question

Not the answer you're looking for? Browse other questions tagged
  • jvmargument

  • xx-printinlining

  • x-printinlining

  • JVM startup parameter