Dive into JVM method profiling to understand how and why method compilation sizes vary. By MichaĆ Zyga.
Zyga’s article offers an in-depth exploration of JVM method profiling, starting with an experiment using a simple loop program. By attaching jhsdb to the running JVM, Zyga demonstrates how to inspect method metadata, counters, and data structures like MethodCounters and MethodData.
The author explains how the JVM increments counters by 2 for performance reasons and uses invoke_mask and backedge_mask to determine when to check for compilation to a higher tier. The article covers four tiers of method compilation, illustrating how profiling data changes at each level and explaining the difference between Tier 1 and Tier 2, which collects limited profiling data.
Zyga also discusses deoptimization, showing how the JVM can revert a method to interpreter mode and resume profiling when necessary. By understanding the profiling mechanism and its impact on method compilation sizes, developers can better optimize their Java applications and tune JVM parameters for improved performance. Nice one!
[Read More]