MPLR 2024
The Cost of Profiling in the HotSpot Virtual Machine
Rene Mueller, Maria Carpen-Amarie, Matvii Aslandukov, Konstantinos Tovletoglou
Abstract
Modern language runtimes use just-in-time compilation to execute applications natively. Typically, multiple compiler tiers cooperate so that compilation at a later stage can leverage profiling information generated by earlier tiers. This allows for machine code that is optimized to the actual workload and hardware. In this work, we study the profiling overhead caused by code instrumentation in the HotSpot Java virtual machine for 23 applications from the Renaissance Suite and five additional benchmarks. Our study confirms two common assumptions. First, most applications move quickly through the profiling phase. However, we also show applications that tier up surprisingly slow and, thus, are more affected by profiling overheads. We find that the instrumentation needed for profiling can slow application execution down by up to 35x. A key factor is the memory contention on the shared profiling data structures in multi-threaded applications. Second, most virtual call sites are monomorphic, i.e., they only have a single receiver type. This can further reduce the cost of profiling which receiver types are encountered at virtual call sites. Our analysis suggests that, for the most part, profiling overhead in language runtimes is not a cause for concern. However, we show that there are situations, e.g., in multi-threaded applications, where profiling impact can be consequential.
