High CPU in JVM compiler threads

Solution Verified - Updated

Environment

  • JBoss Enterprise Application Platform (EAP)
  • Java

Issue

  • We see high CPU in our JVM compiler threads

Resolution

  • Limit compiler usage by limiting the compiler thread count and increasing the compiler threshold:
-XX:CICompilerCount=1 -XX:CompileThreshold=20000 -XX:Tier3CompileThreshold=5000 -XX:Tier4CompileThreshold=30000

in the later versions of Java, TieredCompilation is default to true, CICompilerCount will needs to be greater than 1 otherwise JVM will not start, i.e

-XX:CICompilerCount=2 -XX:CompileThreshold=20000 -XX:Tier3CompileThreshold=5000 -XX:Tier4CompileThreshold=30000
  • Increase the size of the code cache to avoid exhaustion. It defaults to 240 mb for java 8. Note this is an additional reserved space outside the heap/meta:
-XX:InitialCodeCacheSize=512m -XX:ReservedCodeCacheSize=512m

Root Cause

  • The code cache may be exhausted, causing frequent flushing and recompiling of frequently used methods

Diagnostic Steps

  • Add -XX:+PrintCompilation to your JVM options for further details on compiler activity. Redirect console output to a file to capture this data.
  • See Solving OpenJDK C2 compilation issues for logging format details, and for PrintCompilation log interpretation.
Components
Category

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.