On Thu, 22 Jun 2023 10:13:18 GMT, 温绍锦 <d...@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: > > use ByteArray & simplify code src/java.base/share/classes/java/lang/Long.java line 492: > 490: ByteArray.setChar(buf, 30, i13); > 491: ByteArray.setChar(buf, 32, i14); > 492: ByteArray.setChar(buf, 34, i15); Suggestion: ByteArray.setLong(buf, 0, ((long) i0 << 48) | ((long) i1 << 32) | ((long) i2 << 16) | i3); buf[8] = '-'; ByteArray.setInt(buf, 9, (i4 << 16) | i5); buf[13] = '-'; ByteArray.setInt(buf, 14, (i6 << 16) | i7); buf[18] = '-'; ByteArray.setInt(buf, 19, (i8 << 16) | i9); buf[23] = '-'; ByteArray.setLong(buf, 24, ((long) i10 << 48) | ((long) i11 << 32) | ((long) i12 << 16) | i13); ByteArray.setInt(buf, 32, (i14 << 16) | i15); JMH Result: Benchmark Mode Cnt Score Error Units - UUID.test thrpt 5 87196.091 ± 492.129 ops/ms + UUID.test thrpt 5 99197.287 ± 925.266 ops/ms ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/14578#discussion_r1238363498