RFR: 8315098: Improve URLEncodeDecode microbenchmark [v3]

Francesco Nigro duke at openjdk.org
Wed Aug 30 15:55:13 UTC 2023


On Wed, 30 Aug 2023 15:43:13 GMT, Claes Redestad <redestad at openjdk.org> wrote:

>> test/micro/org/openjdk/bench/java/net/URLEncodeDecode.java line 86:
>> 
>>> 84:         tokens[n++] = '*';
>>> 85: 
>>> 86:         Random r = new Random(mySeed);
>> 
>> SplittableRandom allow to have perfectly reproducible sequences
>
> Care to elaborate? `Random` with an explicit seed should be more than enough to have perfectly reproducible sequences for our case (`SplittableRandom` uses a different algorithm by default with a longer period, but I can't see how this'd be relevant to this case.)
> 
> 
>  * If two instances of {@code Random} are created with the same
>  * seed, and the same sequence of method calls is made for each, they
>  * will generate and return identical sequences of numbers.

Even with the same seed only with large numbers you get statistically a similar distribution,m (not the same values, but the javadoc said differently which is quite surprising to me!), but splittable random is actually producing the same exact sequences. You care about confusing branch predictors here I suppose (or the JIT, maybe too) but not to add noise or variance with fewer samples nor you are interested to the security part of it (cause random use the chaos generated securely by the OS/HW iirc).

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/15448#discussion_r1310489744


More information about the net-dev mailing list