Closed puzpuzpuz closed 3 years ago
@pborman thanks for the review!
Hi !
Just a quick question:
why not use bufio.Reader
?
Is it to heavy/complex ?
why not use
bufio.Reader
? Is it to heavy/complex ?
@pierrre
TBH I didn't consider bufio.Reader
when writing the code. The logic seems to be pretty straight-forward to me, so I kept the code simple and used a plain array + a position variable. But I guess, bufio.Reader
would also work just fine.
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.