Proposal for two new samples

Aleksey Shipilev aleksey.shipilev at oracle.com
Mon Jul 27 21:52:46 UTC 2015


Hi Michael,

On 07/28/2015 12:22 AM, Michael Mirwaldt wrote:
> I would like to add two samples I miss in the jmh repository.
> They could help jmh users to experience the effect and demonstrate that
> on their lectures.
> 
> 1) Branch prediction
> - it demonstrates how branch prediction/misprediction can lead to
> better/worse performance.

Yes, that one is sure missing. This touches on benchmarking methodology
that tells you might need to feed the benchmark with the data arranged
in a way you have it in a real world. Therefore, it is a good addendum
to JMH Samples.


> - I could not check whether the branch misses ratio increases.
> If you are interested I will do so and should observe that with the
> command line tool perf on a linux machine.

It would make sense to employ -prof perfnorm or -prof perfasm in the
explanation for the effect.


> 2) Matrix copy

The cache behavior example is interesting, but I wonder if we can
somehow construct an example where an innocuously looking *methodology*
omission backfires a lot. Walking the matrix in one way or the other
seems to be a code-under-test implementation issue, not the methodology
quirk?

For example, could the similar cache unfriendliness be demonstrated on
comparing iteration through HashMap and TreeMap with the same number of
elements (under the misguided assumption both have the same memory
footprint)?

> Are the results 'significant in numbers' for you?

Yes, they are.

> How can I submit my sample code so that you can try it out/review them?

Sure. The contributions to JMH are governed by the same rules as
OpenJDK. I see you have the OCA signed and submitted, so we are in
clear. Show us your code!

Thanks,
-Aleksey



More information about the jmh-dev mailing list