criteo / haproxy-spoe-go

An implementation of the SPOP protocol in Go. https://www.haproxy.org/download/2.0/doc/SPOE.txt
Apache License 2.0
28 stars 14 forks source link

Performance: change user interface to reduce allocs #10

Closed ShimmerGlass closed 4 years ago

ShimmerGlass commented 4 years ago

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.

ShimmerGlass commented 4 years ago

@pierresouchay, ya there is no version currently for this lib. I'm planning on releasing v1.0.0 after these two are merged

pierresouchay commented 4 years ago

@ShimmerGlass There are confllicts

ShimmerGlass commented 4 years ago

@pierresouchay rebased