How do I reduce the amount of CPU being consumed by Just In Time (JIT) compilation?

JIT optimizes your bytecode but can also consume high CPU. If you are facing high CPU usage issues and find that that JIT compiler threads are the culprits, you can try some optimization flags related to JIT

In thread dumps you will find JIT compiler threads like this :

“C1 CompilerThread2” #8 daemon prio=9 os_prio=2 tid=0x000000fdf94c6800 nid=0xba0 waiting on condition [0x0000000000000000]
java.lang.Thread.State: RUNNABLE

“C2 CompilerThread1” #7 daemon prio=9 os_prio=2 tid=0x000000fdf94c3000 nid=0x34c runnable [0x0000000000000000]
java.lang.Thread.State: RUNNABLE

“C2 CompilerThread0” #6 daemon prio=9 os_prio=2 tid=0x000000fdf94c1000 nid=0xb54 runnable [0x0000000000000000]
java.lang.Thread.State: RUNNABLE

You can read this article to find high CPU consuming threads Finding high CPU usage threads

Option #1: -XcompilationThreads1

This option will prevent the JIT from using more then 1 compiler thread. The number of compiler threads available is dependent on the number of CPU cores available. For example, if there are 4 cores available to the JVM, then three 3 JIT compiler threads will be available which can consume as much as 75% of the total CPU time available. When there is a backlog of methods waiting to be compiled you could see the JIT using 70% of the total CPU time, with this option in effect that JIT could never use more then 25% of the total CPU time. In systems with even more CPU cores, the reduction in total potential CPU ustage will be even greater.

Option #2: -Xjit:noServer

This option will reduce the amount of inlining. As a result, compilations will be less complex, and CPU usage will be reduced for the compiler thread(s).

Option #3: -Xjit:virtualizationHighDensity

This option enables a series of options that reduce compilation overhead. This option is a very good compromise as it is not as aggressive as “noServer” in option #2 but yet it does make a significant impact on compilation time for most environments.

Uday Ogra

Connect with me at and lets have some healthy discussion :)

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *