-
-
Notifications
You must be signed in to change notification settings - Fork 435
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Faster UUID Generation #3809
Comments
Here are some preliminary results of my jmh benchmarks comparing the proposed changes with our current implementation: Tests run on Java 17 (17.0.4.1 Temurin):Comparison for just generating the UUID (not toString or
Converting a UUID to a String:
Comparison of ways to replace
Comparison of converting a UUID to a String without
Comparison of UUID generation plus converting it to a String without
Tests run on Java 8:Comparison for just generating the UUID (not toString or
Converting a UUID to a String Java 8 vs Java 17:
Comparison of ways to replace
Comparison of converting a UUID to a String without
Comparison of UUID generation plus converting it to a String without
DiscussionSo, depending on the underlying Java Version used, the proposed changes speed up id generation by x4 (Java 17) to x10 (Java 8). Java 8 seems to have a much slower implementation of Both Java versions tested benefit from moving from |
Description
Problem Statement
UUID Strings are used heavily in our SDK and lead to a significant performance impact as reported by some of our users (e.g. #3325).
After some investigation, likely causes are:
.replace("-", "")
)Solution proposal
In addition to making the calls to UUID generation lazy (#3770) the actual generation of the UUID String performance should be improved by:
java.util.Random
instead ofjava.util.SecureRandom
as we do not need to generate unguessable UUIDs (Random
has been vendored into our SDK in [QA] Replace SecureRandom with vendored Random #3783.-
in the UUIDs as.replace
uses regex under the hood which also impacts performanceThe text was updated successfully, but these errors were encountered: