Repository navigation
What changed
The generic (non-Redis) sliding window, token bucket, and leaky bucket limiters
now use a 256-shard, key-hashed lock instead of one mutex per limiter.
Unrelated keys no longer block each other while the same key still serializes
correctly.
Performance
Measured with benchstat, 10 interleaved samples, Apple M4 / Go 1.26.0.
Parallel multi-key throughput:
| Algorithm | Before | After | Change |
|---|---|---|---|
| Sliding window | 787.6 ns | 262.4 ns | -66.7% |
| Token bucket | 823.1 ns | 320.3 ns | -61.1% |
| Leaky bucket | 813.4 ns | 315.4 ns | -61.2% |
Single-key latency and allocations are unchanged. Full methodology and a
control-group comparison will be published in the docs.
Compatibility
No public API changes. No migration steps. Drop-in upgrade from v2.2.0.
go get github.com/AliRizaAynaci/gorl/v2@v2.2.1Pull Requests
- perf(algorithms): shard generic limiter key locks so unrelated keys run in parallel (#30)