Hacker News new | ask | show | jobs
by throwaway894345 341 days ago
Why is it so much faster than `uuid`?
1 comments

It generates entropy 4kb-at-a-time (instead of on each call), and uses a cache-pool instead of single cache behind a lock (which is what standard uuid does in "RandPool=ON" mode).
So this automatically makes it unsafe in case of VM snapshots.

The Linux kernel now has an optimization that makes it safe: https://lwn.net/Articles/983186/

Go should automatically benefit from this, if they use the vDSO getrandom().

Ah cool, the note here is also interesting: https://pkg.go.dev/github.com/google/uuid#EnableRandPool