3 ms·
This is really nice. The sync.Pool based ring buffer is a really clever way to get around the thing that always kills my low latency work in golang. I wonder h
by kasey_junk 7y ago
This is really nice. The sync.Pool based ring buffer is a really clever way to get around the thing that always kills my low latency work in golang.
I wonder how much the type casting costs you’ll see in real world situations? I’ve not benchmarked that generally but it’s always something I worry about with ‘generic’ data structures like this.
- karlmcguire 7y agoThank you. The sync.Pool lossy ring buffers are probably my favorite innovation, especially because of how little code it is. I was worried about type casting as well and generally avoided bare interfaces like the plague. However, in all the benchmarks I've ran for throughput, type casting was a small percentage of CPU time. I'll see if I can dig up a flamegraph. Of course, the only reason sync.Pool performs so well is because of its internal usage of thread local storage. If the Go team exposed that, we could make our own typed sync.Pool implementations... I won't hold my breath, though.