RFR: JDK-8310502 : Optimization for j.l.Long.fastUUID() [v25]

温绍锦 duke at openjdk.org
Tue Jun 27 02:08:23 UTC 2023


On Mon, 26 Jun 2023 09:57:31 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:
> 
>   use ISO_8859_1.INSTANCE directly instead of StandardCharsets.ISO_8859_1

the last implementation (commit id 6b61a715) is the best performant whether CompactStrings is true or false.

when CompactStrings is false, the improvement brought by using ByteArray is greater than the overhead of StringLatin1.inflate. the benchmark result above also confirms this.

because the implemented code is in UUID.toString, there is no need to intrude into the code of java/lang/Long.java, which is clearer and easier to maintain.

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

PR Comment: https://git.openjdk.org/jdk/pull/14578#issuecomment-1608595082


More information about the core-libs-dev mailing list