RFR: 8196334: Optimize UUID#fromString
claes.redestad at oracle.com
Sun Mar 8 14:05:43 UTC 2020
sorry about defaulting to throughput measurement - while average time
has its advantages (especially on nanobenchmarks), most benchmarks are
intuitively "higher is better", so I lean that way by old habit.
Thanks for trying out your ideas, though! It's important we try out and
report the result of reasonable alternatives, even when they fall short.
I've done a number of experiments here that I should have probably made
a note of somewhere...
On 2020-03-08 12:59, Peter Levart wrote:
> Sorry, bash this.
> I just noticed that the units used in benchmark are ops/us and that the
> best performing code is the one which is in place now.
> I usually use ns/op as a unit in JMH benchmarks, so this led me to false
> belief that alternatives are better performing where in fact are worse.
> Sorry for noise.
> Regards, Peter
> On 3/8/20 12:46 PM, Peter Levart wrote:
>> When I noticed this optimization, I had some ideas how to push this
>> even further, but only now had some time to try them out.
>> Here are some incremental improvements  to the already brilliant
>> idea with the following JMH results (the baseline is JDK build with
>> patch for 8196334 already applied):
>> Benchmark (size) Mode Cnt Score Error Units
>> UUIDBench.uuidFromString 20000 thrpt 5 37.344 ± 0.257 ops/us
>> UUIDBench.uuidFromStringAlt1 20000 thrpt 5 29.069 ± 0.137 ops/us
>> UUIDBench.uuidFromStringAlt2 20000 thrpt 5 27.308 ± 0.204 ops/us
>> UUIDBench.uuidFromStringAlt3 20000 thrpt 5 23.195 ± 0.885 ops/us
>> As can be seen, the trick was to eliminate branches (alt1, alt2) and
>> to reduce the number of operations (shifts) in alt3. One last trick in
>> alt3 was to use the array length in a check that is then fused with
>> array index bounds check (I think) so that we get one of them for free.
>> What do you think? Is this good enough to warrant another change? As
>> you can see, I haven't prepared the patch yet, just benchmark.
>> Regards, Peter
>> On 3/2/20 8:26 AM, Claes Redestad wrote:
>>> On 2020-03-02 08:14, Alan Bateman wrote:
>>>> Looks good.
>>> Thanks - pushed!
More information about the core-libs-dev