2 ms·
Instrumenting profilers are also terrible because they make tiny methods look way more expensive than they should be, warping the results. Not only does the ins
by barrkel 11y ago
Instrumenting profilers are also terrible because they make tiny methods look way more expensive than they should be, warping the results. Not only does the instrumentation cost, but they can prevent methods from being inlined, interfere with optimizations, cache, and generally give misleading results.
For a sampling profiler to give meaningful results, it shouldn't be waiting for safepoints. Ideally it would capture stack traces very cheaply (just walk the stack frames, noting the return addresses) and turn those numbers into symbolic locations on its own time. Yes, inlining is going to confuse things - that's the downside of working with optimized code. Optimization inherently intermingles code that may be separated by some distance, and any one instruction may be a fuse of multiple source lines. If your instrumenting profiler prevents this, you're no longer measuring the actual production code.
Java makes it harder, of course, with code on a GC'd heap, dynamic codegen, etc.