Java Tip #7 - Use .hotspot_compiler file to stop compilation
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.
And the console output from the compiler.
$ more .hotspot_compiler
#http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5043395
exclude oracle/jdbc/driver/OraclePreparedStatement executeBatch
### Excluding compile: oracle.jdbc.driver.OraclePreparedStatement::executeBatchThis bug report is similar to the problem we had.
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5043395
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.