RFR: 8353741: Eliminate table lookup in UUID.toString [v4]

Shaojin Wen swen at openjdk.org
Mon May 19 23:07:58 UTC 2025


On Mon, 19 May 2025 20:17:43 GMT, Shaojin Wen <swen at openjdk.org> wrote:

>> Improve the performance of UUID::toString by using Long.expand and SWAR (SIMD within a register) instead of table lookup. Eliminating the table lookup can also avoid the performance degradation problem when the cache misses.
>
> Shaojin Wen has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains 16 additional commits since the last revision:
> 
>  - Merge remote-tracking branch 'upstream/master' into optim_uuid_to_string_202501
>  - simplify code
>  - Remove redundant comments
>  - use Long.expand
>  - Merge remote-tracking branch 'upstream/master' into optim_uuid_to_string_202501
>  - refactor
>  - from j3graham
>  - add comments
>  - use ByteArrayLittleEndian
>  - ues Long.expand
>  - ... and 6 more: https://git.openjdk.org/jdk/compare/f9f2be52...878a3cb7

The latest performance test numbers show that under AMD X64, the performance is improved by about 21%, and under MacBook M1 Pro, the performance is improved by about 7%.

## performance test scripts

git remote add wenshao git at github.com:wenshao/jdk.git
git fetch wenshao

# origin
git checkout bd99525633e4d3d3f180a6678eedb8780dbb6139
make test TEST="micro:java.util.UUIDBench.toString"

# current
git checkout 878a3cb7c73b777eb5385b3e4d158c998cd9be46
make test TEST="micro:java.util.UUIDBench.toString"



## aliyun_ecs_c8a_x64 (CPU AMD EPYC™ Genoa)

-# origin  bd99525633e4d3d3f180a6678eedb8780dbb6139
-Benchmark           (size)   Mode  Cnt   Score   Error   Units
-UUIDBench.toString   20000  thrpt   15  93.320 ± 0.359  ops/us

+# current 878a3cb7c73b777eb5385b3e4d158c998cd9be46
+Benchmark           (size)   Mode  Cnt    Score   Error   Units
+UUIDBench.toString   20000  thrpt   15  113.508 ± 1.372  ops/us +21.63%


## Apple MackBook M1 Pro

-# origin  bd99525633e4d3d3f180a6678eedb8780dbb6139
-Benchmark           (size)   Mode  Cnt    Score   Error   Units
-UUIDBench.toString   20000  thrpt   15  106.199 ± 0.568  ops/us

+# current 878a3cb7c73b777eb5385b3e4d158c998cd9be46
+Benchmark           (size)   Mode  Cnt    Score   Error   Units
+UUIDBench.toString   20000  thrpt   15  113.911 ± 0.628  ops/us +7.34%

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

PR Comment: https://git.openjdk.org/jdk/pull/22928#issuecomment-2892476915


More information about the core-libs-dev mailing list