Unusual behavior of java.util.Optional in benchmark mode

Bernd Eckenfels ecki at zusammenkunft.net
Thu Sep 12 19:01:14 UTC 2019


The ratio between Optional and String instances should however be 1:1 (Optionals of null point all to the same empty Singleton). I wonder if this is a heapdump/Gc/stringtable thing, can you maybe try to add a run-unique string to the value strings?

Gruss
Bernd
--
http://bernd.eckenfels.net

________________________________
Von: jmh-dev <jmh-dev-bounces at openjdk.java.net> im Auftrag von Aleksey Shipilev <shade at redhat.com>
Gesendet: Donnerstag, September 12, 2019 8:40 PM
An: John Auden; jmh-dev at openjdk.java.net
Betreff: Re: Unusual behavior of java.util.Optional in benchmark mode

On 9/12/19 8:32 PM, John Auden wrote:
> I tried to do assembly code analysis, and I see where Optional is
> being created (https://github.com/alex-dubrouski/java-test/blob/master/docs/conditionals/Optional.txt),
> but still can't explain why there are 133 millions of them.
>
> Would be very thankful if you can take a look and help me explain this.

You apparently think that "iteration" is one call to @Benchmark. It is not, there are multiple
invocations of @Benchmark in AverageTime/Throughput modes, which would call @Benchmark continuously,
until time allows.

--
Thanks,
-Aleksey



More information about the jmh-dev mailing list