Skip to content

Use Splittable/ThreadLocalRandom to generate bulk data in tests (#16808) - #16920

Merged
chrisvest merged 1 commit into
netty:5.0from
chrisvest:5.0-splittable-random
Jun 5, 2026
Merged

chrisvest merged 1 commit into
netty:5.0from
chrisvest:5.0-splittable-random

Conversation

@chrisvest

Copy link
Copy Markdown
Member

Motivation:
When we can guarantee single-threaded access to a random number generator, then the SplittableRandom algorithm is dramatically faster than a single shared Random instance. The old Random class is thread-safe, and pay a high cost for this, which is very noticable when generating kilobytes or megabytes of data.

Modification:

  • Go through all uses of the old Random class, and make use of SplittableRandom in ways that ensure single-threaded access.
  • Use ThreadLocalRandom in places where seeding isn't used.
  • Clean up imports in all test classes touched.

Result:
Faster build, shaving tens of seconds off the execution time of some tests.

(cherry picked from commit 9a46934)

…y#16808)

Motivation:
When we can guarantee single-threaded access to a random number
generator, then the SplittableRandom algorithm is dramatically faster
than a single shared Random instance. The old Random class is
thread-safe, and pay a high cost for this, which is very noticable when
generating kilobytes or megabytes of data.

Modification:
- Go through all uses of the old Random class, and make use of
SplittableRandom in ways that ensure single-threaded access.
- Use ThreadLocalRandom in places where seeding isn't used.
- Clean up imports in all test classes touched.

Result:
Faster build, shaving tens of seconds off the execution time of some
tests.

(cherry picked from commit 9a46934)
@chrisvest chrisvest added this to the 5.0.0.Final milestone Jun 5, 2026
@chrisvest
chrisvest merged commit 2301650 into netty:5.0 Jun 5, 2026
13 checks passed
@chrisvest
chrisvest deleted the 5.0-splittable-random branch June 5, 2026 20:04
@normanmaurer normanmaurer mentioned this pull request Sep 22, 2026
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