Skip to content

Generate entryUUID from a per-thread SecureRandom#683

Open
vharseko wants to merge 1 commit into
OpenIdentityPlatform:masterfrom
vharseko:features/adddel-2
Open

Generate entryUUID from a per-thread SecureRandom#683
vharseko wants to merge 1 commit into
OpenIdentityPlatform:masterfrom
vharseko:features/adddel-2

Conversation

@vharseko

@vharseko vharseko commented Jul 3, 2026

Copy link
Copy Markdown
Member

Summary

Companion to #682 from the ADD/DELETE hot-path profiling. The EntryUUID
plugin runs for every LDAP add and used UUID.randomUUID(), which
draws from a single shared static SecureRandom whose engine
(SHA1PRNG/NativePRNG, provider-dependent) synchronizes nextBytes
one more JDK-internal monitor that all concurrent adds serialize on.

Change

Generate the RFC 4122 version 4 UUID from a
ThreadLocal<SecureRandom>: 16 random bytes with the version and variant
bits set exactly as UUID.randomUUID() sets them. Format verified
standalone — 200,000 generated UUIDs, all unique, version()==4,
variant()==2, matching the reference implementation. The deterministic
DN-based UUID used for LDIF import (parallel-import reproducibility) is
unchanged.

Honest performance note

No local throughput change is expected or claimed on the benchmark host:
the concurrent add path is dominated by JE record-lock waits on shared
index keys (~822 s of waitForLock per 80 s JFR window in the ADD/DELETE
baseline — see #682) and by the JE write-ahead log. The SecureRandom
monitor is held for microseconds; this removes a JDK-internal
serialization point whose relative weight grows with core count and add
rate — the same structural rationale as the rest of the series.

Testing

mvn -P precommit -pl opendj-server-legacy verify:
EntryUUIDPluginTestCase (61 — behavioural validation of the generated
attribute through the UUID syntax), AddOperationTestCase (137):
198 tests, 0 failures. Plus the standalone 200k-UUID format check
described above.

Files

  • opendj-server-legacy/src/main/java/org/opends/server/plugins/EntryUUIDPlugin.java

The EntryUUID plugin runs for every LDAP add and used UUID.randomUUID(),
which draws from a single shared SecureRandom whose engine is
synchronized — one more monitor all concurrent adds serialize on.

Generate the RFC 4122 version 4 UUID from a ThreadLocal<SecureRandom>
instead: same format (version and variant bits set identically, verified
against UUID.randomUUID), same uniqueness guarantees, no shared state.
The deterministic DN-based UUID used for LDIF import is unchanged.

No measurable local throughput change is expected or claimed: the add
path is dominated by JE record-lock waits on shared index keys; this
removes a JDK-internal serialization point that grows with core count.
@vharseko vharseko added this to the 5.2.0 milestone Jul 3, 2026
@vharseko vharseko requested a review from maximthomas July 3, 2026 20:13
@vharseko vharseko added the performance Performance / concurrency / lock-contention work label Jul 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement performance Performance / concurrency / lock-contention work

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants