Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
crypto/rand: Reader is internally buffered inconsistently on different platforms #16593
Please answer these questions before submitting your issue. Thanks!
On my machine, internally buffering the output of Read doubled performance compared with raw Reads. Tv` suggested that the unbuffered Reads may be quicker when multithreaded due to bufio adding a mutex. He wrote a benchmark to test this theory but it turned out not to be true:
Not buffering is actually a nice feature of the
What's the situation where the syscall performance is a problem? (Is it CBC-mode in TLS again?)
Still applies to 1.12 and tip. See #33256 for benchmarks showing order-of-magnitude differences for small reads via a bufio.Reader.
Don't these apply equally to the entropy pool in the kernel? Why is it a concern only for entropy buffered in process? (Also note that the /dev/urandom fallback already buffers.)
We ran into this in the profile of a workload where we need to generate tokens for authentication (unrelated to TLS).