On Wed, 21 Jun 2023 07:28:54 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 src/java.base/share/classes/java/lang/Long.java line 97: > 95: + (lo < 10 ? '0' + lo : 'a' + lo - 10)); > 96: } > 97: } Are you checking the impact on startup? I guess I would have expected to see it loaded from the CDS archive. Given that the usage is just UUID::toString then maybe you could move this to a holder class containing a Stable array, at least until there is a better way to have lazily computed constants. Another thing to try is moving fastUUID out of Long - moving to an array of precomputed hex values means it is not tied to Long internals anymore. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/14578#discussion_r1236556426