Detecting when compilations occur

Petr Tůma petr.tuma at d3s.mff.cuni.cz
Fri Oct 13 06:17:19 UTC 2017


Hi Arthur,

some options, depending on what exactly you want:

- you could catch the JVMTI CompiledMethodLoad event callback, this 
needs a C agent but otherwise should work quite well

- you could query the CompilationMXBean in java.lang.management, this 
gives you the aggregate compilation time in milliseconds (this will jump 
forward on compilation end but sub millisecond compilation events will 
not be visible)

- you can monitor the execution time of the compiler threads

- you can enable the JVM compilation log (-XX:+PrintCompilation), this 
includes time relative to JVM start so can be correlated with benchmark 
iterations if they are long enough

Some of these are implemented in 
https://github.com/D-iii-S/java-ubench-agent, you can take a look for 
inspiration.

Hope this helps, Petr


On 13/10/17 02:47, Arthur Peters wrote:
> Is there any way to detect when Truffle/Graal compilations happen? (for
> instance by getting a callback or even just accessing a count of how
> many compilations have happened so I can check if it has changed.)
> 
> I would like to have this information for my benchmarking so I can
> easily tag repetitions of the benchmark that have a compilation. This
> would be useful for analyzing how fast the code generated by the
> compiler is independent of the compiler itself and visa versa.
> 
> -Arthur
> 
> PS: I'm not going to just remove all the repetitions with compilations.
> That would not really represent the performance of the language. But it
> would be nice to be able to do subgroup analysis.
> 


More information about the graal-dev mailing list