The previous implementation, while user friendly, required a lot of
allocations on the hot path. This changes it for an iterator based
implementation that, along with a few smaller optimization, reduces the
allocs by 82% and improves latency by 25%.
Benchmarks comparison:
benchmark old ns/op new ns/op delta
BenchmarkSPOE-6 32842 24653 -24.93%
benchmark old allocs new allocs delta
BenchmarkSPOE-6 23 6 -73.91%
benchmark old bytes new bytes delta
BenchmarkSPOE-6 1079 193 -82.11%
This branch is based on timeouts for convenience. I'll rebase it afterwards.
The previous implementation, while user friendly, required a lot of allocations on the hot path. This changes it for an iterator based implementation that, along with a few smaller optimization, reduces the allocs by 82% and improves latency by 25%.
Benchmarks comparison:
This branch is based on
timeouts
for convenience. I'll rebase it afterwards.