Allocations profiler
Aleksey Shipilev
aleksey.shipilev at oracle.com
Fri Feb 20 10:25:54 UTC 2015
Hi Ben,
On 02/19/2015 10:23 PM, Ben Manes wrote:
> It would nice if the benchmark results included the average number of
> allocations that occurred per execution. This would probably be best
> done using a JMH profiler and can be implemented using a Java agent
> like Jeremy Manson's java-allocation-instrumenter.
You have to understand that the intrusive profiling like that affects
benchmark results. *Especially* if you do stuff on each object
allocation. E.g. the fast TLAB allocation takes around 10 ns. Accounting
the allocated object in the profile would probably cost another 10-20 ns
at best. That's already 2-3x performance hit on allocation path.
> This basic usage could be extended to include a breakdown of the
> count and type of objects allocated, which could be useful to
> identity unintended allocations. A profiler like YourKit helps in
> this regard, but much coarser and harder to compare when benchmarking
> to chose between implementation techniques. Go's benchcmp tool
> includes the allocation count in its results and a recent blog post
> showed how it was a useful metric when performance optimizing a
> library.
I am not sure how they are able to pull off low-overhead profiling like
that.
Either way, you are welcome to try hacking together such a profiler, and
see what happens. If you decide to contribute the code to OpenJDK/JMH,
please sign the OCA:
http://openjdk.java.net/contribute/
Thanks,
-Aleksey.
More information about the jmh-dev
mailing list