0

Help me to understand difference between JVMTI_EVENT_COMPILED_METHOD_* and JVMTI_EVENT_DYNAMIC_CODE_GENERATED for OpenJDK 8.
I counts this events for visualization at Grafana but don't understand them to the end.

Maybe it is "Interpretator" and "C2/C1" or somethings also.
Can you explain when this events occurred.

I've read https://docs.oracle.com/javase/8/docs/platform/jvmti/jvmti.html#CompiledMethodLoad but I still cannot understand differents.
Thanks.

srg321
  • 105
  • 7

1 Answers1

2

CompiledMethodLoad event corresponds to JIT compilation of a Java method.

DynamicCodeGenerated event is sent when the JVM generates code for something that is not a Java method: various runtime stubs, handlers, adapters and so on. The bytecode interpreter in HotSpot is also generated dynamically at the VM startup, so the same event is sent when the Interpreter is generated.

Some examples of code blobs, for which DynamicCodeGenerated event is sent:

  • Interpreter
  • flush_icache_stub
  • DeoptimizationBlob
  • I2C/C2I adapters
  • AbstractMethodError throw_exception
  • jlong_disjoint_arraycopy
  • slow_subtype_check Runtime1 stub
  • itable stub
  • etc.

JIT compiler threads are not involved in generation of these blobs. These code blobs are produced either during VM bootstrap, or on demand from a VM runtime function.

Try vmtrace agent from jvmti-tools - it will show you all CompiledMethodLoad and DynamicCodeGenerated events, as well as some other JVM TI events.

apangin
  • 92,924
  • 10
  • 193
  • 247
  • Thank for answer! May be you can explain what does mean CompiledMethodUnLoad. Is it "JIT deoptimization"? – srg321 Oct 12 '20 at 18:41
  • Is performance degradation possible if you listen to these events as at https://github.com/odnoklassniki/jvmti-tools/blob/master/vmtrace/vmtrace.cpp ? – srg321 Oct 12 '20 at 18:47
  • 1
    @srg321 `CompiledMethodUnload` is sent when a previously JIT-compiled method is sweeped (completely removed from Code Cache). Deoptimization does not always lead to sweeping. – apangin Oct 12 '20 at 18:49
  • 1
    Those are very cheap events - they typically don't affect performance, unless you do something really heavy in the event handler. – apangin Oct 12 '20 at 18:52
  • hmmm, I thought Flush(sweeped) is executed only when CodeCache is full.... I don't understand at all :) – srg321 Oct 12 '20 at 19:23
  • @srg321 and during class unloading – apangin Oct 12 '20 at 20:05
  • It's very useful for me :) Thanks! But I don't understand when Class can unloaded because it's impossible while its classloader have reference to it. This document https://docs.oracle.com/javase/8/docs/platform/jvmti/jvmti.html#ClassLoad also doesn't contain anything about ClassUnLoad. However, I performed an experiment and it showed that if there is free space in the CodeCache(MBean "used"), it still happens CodeCacheFlushing(sweep). Why is it happening? :) – srg321 Oct 13 '20 at 07:03
  • @srg321 I'm not sure I understand what you mean. Ask a separate question, as it's too long for a comment, and not related to the original discussion anyway. – apangin Oct 13 '20 at 09:02