5

We have a server application with java IO operations. When running the application, we have observed CPU usage for CompilerThread0 and CompilerThread1 taking 45% and 41% CPU. The application is serving IO to the clients at this time like connect, receive and send. As far as I explored related to this I found that the compilerthread is for JIT and for increasing performance.

My question is first, why it is taking much CPU for the compilerthreads and how to minimize this so that we can give CPU to other threads.

Thanks in advance!

2 Answers 2

7

My question is first, why it is taking much CPU for the compiler threads

Under normal circumstances, the JIT compiler should kick in after your application has been running for a bit to (progressively) compile the classes / methods that are called frequently. Compilation activity should die down ... once all code that needs to be compiled has been compiled.

If the compilation activity doesn't die down, then something strange is happening. It could be one of the following:

  • Your application is making a lot of use of dynamic proxies, and you keep generating new proxy classes.
  • Your application is dynamically loading (and unloading) lots of classes.
  • You've encountered a JVM bug of some sort. (But I couldn't spot a Bug Database entry that matches these symptoms. So I'd call this "unlikely".)

and how to minimize this so that we can give CPU to other threads.

There are potentially JVM options that might help, but I think you'd be better off figuring out what is causing this.

Sign up to request clarification or add additional context in comments.

1 Comment

I will check for the above suggestions and hope will get the cause.
0

In addition to the @Stephen answer above, if the compiler thread consumed more CPU than usual, it is probably a sign of insufficient CodeCache area. For JDK8 the default size for the server VM is 48MB.

Codecache Tuning

Profile your program to find how much of the CodeCache area your program uses. Increase the size by using -XX:ReservedCodeCacheSize option. For example, we increased our online service monolithic CodeCacheSize to 100MB by using -XX:ReservedCodeCacheSize=100M.

After the CodeCache area increased, CPU utilization reduced to 7-10% captured by Dynatrace monitoring.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.