Skip to content
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

Use lower-entropy random UUIDs #2358

Open
alecgrieser opened this issue Nov 14, 2023 · 0 comments · May be fixed by #2359
Open

Use lower-entropy random UUIDs #2358

alecgrieser opened this issue Nov 14, 2023 · 0 comments · May be fixed by #2359
Assignees

Comments

@alecgrieser
Copy link
Contributor

The Java function UUID.randomUUID uses a cryptographically secure random number generator. This can lead to performance bottlenecks for highly concurrent use cases, as there is a lock around the random number generator. However, for effectively all of our random UUIDs (with maybe one exception, in the R-tree), we don't really need secure randomness, and so the lock maintenance is wasted effort.

@alecgrieser alecgrieser self-assigned this Nov 14, 2023
alecgrieser added a commit to alecgrieser/fdb-record-layer that referenced this issue Nov 14, 2023
To avoid synchronization, calls to the high-entropy `java.util.UUID.randomUUID` method are replaced here with calls to a new method that takes a configurable source randomness (defaulting to a thread-local random). This should be more performant, due to the removal of some synchronization points. In most cases, we don't have a need for cryptographically secure UUIDs. For instance, this is used by the planner to assign IDs, but all of the planner objects are created within the same thread, so the thread-local random should be sufficient. The R-tree also uses UUIDs for that purpose, but there, the uniqueness of the UUIDs is important for ensuring uniqueness of different nodes in the tree, so that usage has not been updated here.

This resolves FoundationDB#2358.
@alecgrieser alecgrieser linked a pull request Nov 14, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant