Rendered at 22:56:11 GMT+0000 (Coordinated Universal Time) with Cloudflare Workers.
jzelinskie 2 hours ago [-]
"Understanding _using_ singleflight in Go" would be a better title. This generated article doesn't give the reader a real understanding of the implementation and its various tradeoffs that you might care about depending on your workload (e.g. should the first execution to reach a key spawn a goroutine or is that allocation too much)
That being said, singleflight is a fantastic library and pattern that helps so much with p95 latency. It's a little noisy code-wise, but if you use it in the right places the gains are huge.
Also, totally agree with the below comment that recommends janos/singleflight -- start there, but most of the critical projects at my company, AuthZed, have reimplementations with tailored semantics.
mholt 9 minutes ago [-]
First I've heard of this. Lazyweb, why would I use this over sync.Once?
0x696C6961 5 minutes ago [-]
It has error handling.
theowaway213456 1 hours ago [-]
This implementation is better than stdlib's implementation in my opinion, since it respects context:
That being said, singleflight is a fantastic library and pattern that helps so much with p95 latency. It's a little noisy code-wise, but if you use it in the right places the gains are huge.
Also, totally agree with the below comment that recommends janos/singleflight -- start there, but most of the critical projects at my company, AuthZed, have reimplementations with tailored semantics.
https://github.com/janos/singleflight