crypto/rand: Read performance improvements #33256
Labels
FrozenDueToAge
Performance
WaitingForInfo
Issue is not actionable because of missing required information, which needs to be provided.
Wrapping
crypto/rand.Reader
in abufio.Reader
amortizes the syscall overhead significantly, especially for smaller reads (number of bytes per read after the/
). This is obviously a quick and dirty test - I don't think it's a good idea to bluntly wrap it like this, but it's just to show that there are potential gains to be had by buffering reads fromgetrandom
:While on topic, it may be worthwhile to point out that short reads from
getrandom
don't need to be discarded, as they can be still used:go/src/crypto/rand/rand_batched.go
Lines 39 to 42 in 9195948
Environment:
Benchmark
The text was updated successfully, but these errors were encountered: