RFR: 8310502 : optimization for UUID#toString [v4]
Roger Riggs
rriggs at openjdk.org
Wed Jun 21 14:56:06 UTC 2023
On Wed, 21 Jun 2023 14:39:18 GMT, 温绍锦 <duke at openjdk.org> wrote:
>> By optimizing the implementation of java.lang.Long#fastUUID, the performance of the java.util.UUID#toString method can be significantly improved.
>>
>> The following are the test results of JMH:
>>
>> Benchmark Mode Cnt Score Error Units
>> UUIDUtilsBenchmark.new thrpt 5 92676.550 ± 292.213 ops/ms
>> UUIDUtilsBenchmark.original thrpt 5 37040.165 ± 1023.532 ops/ms
>
> 温绍锦 has updated the pull request incrementally with one additional commit since the last revision:
>
> add annotation Stable
src/java.base/share/classes/java/lang/Long.java line 563:
> 561: StringUTF16.putChar(buf, 7, (byte) i3);
> 562: StringUTF16.putChar(buf, 8, '-');
> 563: StringUTF16.putChar(buf, 9, (byte) (i4 >> 8));
This might be cheating but you could avoid a store of 0 to the high byte (its already zero) by inlining the code from StringUTF16.putChar(); just double the index on the store of the byte.
buf[0] = (byte) (i0 >> 8);
buf[2] = (byte) i0;
buf[4] = (byte) (i1 >> 8);
buf[6] = (byte) i1;
buf[8] = (byte) (i2 >> 8);
...
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/14578#discussion_r1237143688
More information about the core-libs-dev
mailing list