java - How is jProfiler handling JIT? -
i use jprofiler extensively , great tool wondering how jprofiler handling effects of jit compilation.
am able observe example method inlining? if method inlined, not visible in snapshot @ or jprofiler still able compute execution time?
similarly, a method has no side effects , can optimized away not shown in jprofiler. correct?
i profile applications after quite long warmup time expect code jit-ed/optimized possible. therefore, methods suspect should optimized away , yet visible in profile big mystery me.
i use jprofiler extensively , great tool wondering how jprofiler handling effects of jit compilation.
just-in-time compilation rather old technology replace hotspot adaptive optimizer. jit blindly compiles every method java bytecode native code, , may (or may not) able optimize well.
however, adaptive optimizer looks @ how code runs right now , optimizes code being executed often. because optimizer aware of how code being used, optimizer can , better method inlining, branch prediction, lock coarsening, loop unwinding , more.
am able observe example method inlining? if method inlined, not visible in snapshot @ or jprofiler still able compute execution time?
jprofiler not report methods have been inlined; however, happily report invocations, if compiler placed them inline in method.
how? well, during compilation, compiler demarcs method boundaries in native code. essential jvm able reconstruct stack trace when exception or error occurs. when jvm sampled, jvm responds stack traces of executing threads, , current method accurately reported, if inlined.
similarly, method has no side effects , can optimized away not shown in jprofiler. correct?
you correct. method no side effects or computed return value or call method possible side effect entirely optimized out, but there fossil remnant in jvm records method would have been called. marginal overhead extremely small, has following interesting characteristics:
- when sampling, highly unlikely method ever on stack @ moment of sampling, not detected jprofiler (or other sampling profilers).
- when instrumenting, profiler traces method calls , will detect method call. total cost be, mentioned above, trivially small.
the difference in sampling vs. instrumenting explained in this article.
Comments
Post a Comment