On Thu, 22 Jun 2023 07:16:25 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: > > fix compile error > I've tested the benchmarks and the patch and baseline (with extra stable > annotation) with a slightly varied version suitable for gradle run: > > ```java > package com.alibaba.openjdk; > > import org.openjdk.jmh.annotations.Benchmark; > import org.openjdk.jmh.annotations.BenchmarkMode; > import org.openjdk.jmh.annotations.Fork; > import org.openjdk.jmh.annotations.Measurement; > import org.openjdk.jmh.annotations.Mode; > import org.openjdk.jmh.annotations.OutputTimeUnit; > import org.openjdk.jmh.annotations.Warmup; > import org.openjdk.jmh.infra.Blackhole; > > import java.util.UUID; > import java.util.concurrent.TimeUnit; > > @BenchmarkMode(Mode.Throughput) > @OutputTimeUnit(TimeUnit.MILLISECONDS) > @Warmup(iterations = 3, time = 10) > @Measurement(iterations = 6, time = 5) > @Fork(1) > public class UUIDUtilsBenchmark { > public static UUID uuid = UUID.randomUUID(); > > @Benchmark > public void jdk(Blackhole bh) { > bh.consume(uuid.toString()); > } > > @Benchmark > public void fast(Blackhole bh) { > bh.consume(UUIDUtils.fastUUID(uuid)); > } > } > ``` > > The throughput varies a lot between iterations somehow; the patch and > baseline with stable has no significant difference (i.e. within the error > range, about 10%) the performance of this improvement varies among different environments, with a significant improvement on the MacBookPro M1 Max chip (my laptop) and only about 10% improvement on Linux servers (Intel Xeon(Sapphire Rapids) Platinum and Aliyun Yitian 710 arm CPU and Orange Pi 5 Plus). ------------- PR Comment: https://git.openjdk.org/jdk/pull/14578#issuecomment-1602144426