These are chat archives for HotswapProjects/user

17th
Jan 2017
Saqib Ahmed
@saqibahmed515
Jan 17 2017 07:03
Hi, I'm using DCEVM to instrument some of my classes at runtime. I'm doing dynamic bytecode instrumentation using a JVMTI agent. I have to instrument those methods which are "hot", that is, the methods which invoke JIT compiler. To do so I listen to a CompiledLoadEvent and inside its call back function, call RetransformClasses. This in turn invokes ClassFileLoadHook on the class containing "hot" function and actual instrumentation begins. Currently I'm instrumenting my class to spawn some threads. I also listen to thread starts and print them within my agent.
Saqib Ahmed
@saqibahmed515
Jan 17 2017 07:08

The problem is, when I instrument my hot methods, my code gets instrumented perfectly but takes a lot of time (I guess the C1 compiler bails out and interpreter starts again).
Is there any way of restricting the JVM to use the compiler even after the instrumentation (If that is causing the actual overhead)?
Can I use any other strategy to get the profiler's feedback to instrument hot methods so that I don't get any overhead after instrumentation?

I have checked my agent with ClassFileLoadHook event at class load time and it works perfectly without any overhead.