Skip to content

Use ThreadLocal caching for ExtendedRandom PRNG contexts#1511

Open
taoliult wants to merge 1 commit into
IBM:java11from
taoliult:java11_securerandom_native_2
Open

Use ThreadLocal caching for ExtendedRandom PRNG contexts#1511
taoliult wants to merge 1 commit into
IBM:java11from
taoliult:java11_securerandom_native_2

Conversation

@taoliult
Copy link
Copy Markdown
Collaborator

@taoliult taoliult commented Jun 3, 2026

Add ThreadLocal caching for native PRNG contexts used by ExtendedRandom. Each thread creates and reuses a PRNG context for supported DRBG algorithms.

This avoids repeated EXTRAND_create calls when instances are created frequently.

Benefits:

  • Reduce native allocation overhead
  • Reuse PRNG contexts per thread
  • Improve performance in RNG-heavy workloads

This PR is back-ported from PR #1255

Add ThreadLocal caching for native PRNG contexts used by
ExtendedRandom. Each thread creates and reuses a PRNG
context for supported DRBG algorithms.

This avoids repeated EXTRAND_create calls when instances
are created frequently.

Benefits:
- Reduce native allocation overhead
- Reuse PRNG contexts per thread
- Improve performance in RNG-heavy workloads

Signed-off-by: Tao Liu <tao.liu@ibm.com>
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 this pull request may close these issues.

1 participant