Monday, January 24, 2005

Java Tip #7 - Use .hotspot_compiler file to stop compilation

The hotspot compiler has known bugs that can cause the compilation thread to go cpu bound. We had seen this behavior occasionally in production. A customer would call & report that no one was logged into the system, but it was at 100% on one cpu. The instance would normally be restarted & things would be fine. We couldn't figure out why & of course the customer was frustrated at having to restart the system. I can't blame 'em. For a time we had no clue what was causing the problem.

Recently we did some load testing at Sun's Market Development Engineering lab (very cool, btw) and really stressed our application. We kept seeing this "java/9" thread go to 100% cpu during the warmup period. It didn't happen every time, but it happened often enough to slow us down. The busy process was visible in prstat using the -L flag to list lightweight processes (lwp). We used pstack to look at the offending lwp & saw it was the hotspot compiler. We applied the +XX:PrintCompilation vm flag and found that the compilation was stopping at various times & it always seemed to happen on the same methods. We used the .hotspot_compiler file to exclude various methods and the stuck thread problem was solved.

The .hotspot_compiler file goes in working directory & has a line for each method to be excluded.
For example:
exclude com.whatever.TheClassName theMethodName

This would prevent the com.whatever.TheClassName.theMethodName() from being compiled.

Here's a "more" listing of a file with a single entry.

$ more .hotspot_compiler
exclude oracle/jdbc/driver/OraclePreparedStatement executeBatch
And the console output from the compiler.
### Excluding compile:  oracle.jdbc.driver.OraclePreparedStatement::executeBatch

This bug report is similar to the problem we had.

According to the bug report, this is resolved in tiger aka 1.5. When we rerun our load tests in June 2005, I will know for sure.


Post a Comment

<< Home