3 ms·
Much faster (~10x) than standard github.com/google/uuid package I'm interested in feedback from the HN community.
by sdrapkin 1y ago
Much faster (~10x) than standard github.com/google/uuid package
I'm interested in feedback from the HN community.
- throwaway894345 1y agoWhy is it so much faster than `uuid`?
- sdrapkin 1y agoIt 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).
- cyberax 1y agoSo 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/ https://lwn.net/Articles/983186/ Go should automatically benefit from this, if they use the vDSO getrandom().
- maxmcd 1y agoAh cool, the note here is also interesting: https://pkg.go.dev/github.com/google/uuid#EnableRandPool https://pkg.go.dev/github.com/google/uuid#EnableRandPool
- evil-olive 1y agowhat real-world problem, if any, does 10x faster UUID generation solve? from your readme, `guid.New()` is 6~10 ns, so presumably the standard UUID package takes 60-100 ns? say I generate a UUID, and then use that UUID when inserting a row into my database, let's say committing that transaction takes 1 msec (1 million ns) if I get a speedup of 90 ns from using a faster UUID package, will that even be noticeable in my benchmarks? it seems likely to be lost in the noise. honestly, this seems like going on a 7-day road trip, and sprinting from your front door to your car because it'll get you there faster.
- sdrapkin 1y agoAmazon AWS S3 web servers process millions of requests per second, and each response generates a random Request-Id. It’s not exactly 16 bytes, but this is a very realistic scenario where guids are used in hot path. If you are writing a cute-kitten blog, might as well use Python instead..