-
Notifications
You must be signed in to change notification settings - Fork 376
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Add randomness pool mode for V4 UUID #80
Conversation
Adds an optional randomness pool mode for Random (Version 4) UUID generation. The pool contains random bytes read from the random number generator on demand in batches. Enabling the pool may improve the UUID generation throughput significantly. Since the pool is stored on the Go heap, this feature may be a bad fit for security sensitive applications. That's why it's implemented as an opt-in feature.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Over all this is fine, just need to add the note about non-threadsafe calls.
@pborman thanks for the review! |
Hi ! |
@pierrre |
* Add randomness pool mode for V4 UUID Adds an optional randomness pool mode for Random (Version 4) UUID generation. The pool contains random bytes read from the random number generator on demand in batches. Enabling the pool may improve the UUID generation throughput significantly. Since the pool is stored on the Go heap, this feature may be a bad fit for security sensitive applications. That's why it's implemented as an opt-in feature. * fixup! document thread-safety aspects
Adds an optional randomness pool mode for Random (Version 4) UUID generation. The pool contains random bytes read from
the random number generator on demand in batches. Enabling the pool may improve the UUID generation throughput significantly.
Since the pool is stored on the Go heap, this feature may be a bad fit for security sensitive applications. That's why it's implemented as an opt-in feature.
Please treat this PR as a performance experiment.
Benchmarks
Environment: Ubuntu 20.04, go version go1.16.2 linux/amd64, i5-8300h
master
branch:This branch:
The
BenchmarkUUID_NewPooled
benchmark here stands for the pool mode. The pool size could be increased from current 256 bytes to gain a slightly better throughput, but that would come at the cost of larger memory footprint.