What’s So Hot in HotSpot?

HotSpot JVM is the primary reference Java Virtual Machine implementation. The name comes from the approach it takes toward compiling the code. Hot spot is the code which is executed frequently. The more frequently code is executed, the hotter it becomes. If HotSpot JVM finds that kind of code, it will compile it to make it faster. The reasoning behind it is that the performance of an application depends primarily on how fast a hot code is executed. These are the critical sections of the application performance.

 

The obvious question you might ask is why not to compile the whole code at the beginning? The main reason is that it’s not always necessary. Some sections of code won’t be executed frequently, some sections might be executed only once. In that cases, it’s just faster to interpret Java bytecode instead of compiling everything upfront. Secondly, JIT compiler can perform better optimizations if it knows the code paths better. So during a warm-up period, the compiler can learn how the code is executed and benefit from this knowledge (see the difference between “learning” server compiler and more “dummy” client one).

 

Leave a Reply

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