Skip to content

v0.11.0: Improve performance of in-memory rate-limit counter

Compare
Choose a tag to compare
@VojtechVitek VojtechVitek released this 25 Jul 10:46
· 11 commits to master since this release
6678579
  • Improves throughput by 2.6x πŸš€
  • Reduces memory footprint and allocations by 2x πŸ“‰
$ benchstat old.txt new.txt
goos: darwin
goarch: arm64
pkg: github.com/go-chi/httprate
               β”‚   old.txt   β”‚               new.txt               β”‚
               β”‚   sec/op    β”‚   sec/op     vs base                β”‚
LocalCounter-8   34.65m Β± 3%   13.50m Β± 2%  -61.04% (p=0.000 n=10)

               β”‚   old.txt    β”‚               new.txt                β”‚
               β”‚     B/op     β”‚     B/op      vs base                β”‚
LocalCounter-8   4.384Mi Β± 0%   2.846Mi Β± 0%  -35.07% (p=0.000 n=10)

               β”‚   old.txt   β”‚               new.txt               β”‚
               β”‚  allocs/op  β”‚  allocs/op   vs base                β”‚
LocalCounter-8   253.9k Β± 0%   121.6k Β± 0%  -52.12% (p=0.000 n=10)