perf: replace cidranger with bart for significant performance improvements (#675)
* feat: replace cidranger with bart improving performance by 3-20x Signed-off-by: Jason Cameron <git@jasoncameron.dev> * perf: replace cidranger with bart for IP range checking - Replace cidranger.Ranger with bart.Lite in RemoteAddrChecker - Use netip.ParsePrefix instead of net.ParseCIDR for modern IP handling - Improve performance: 3-20x faster lookups with zero heap allocations - Update imports to use github.com/gaissmai/bart and net/netip - Remove cidranger dependency from go.mod Benchmark results: - IPv4 lookups: 4x faster (15.58ns vs 63.25ns, 0 vs 2 allocs) - IPv6 lookups: 3x faster (26.51ns vs 76.96ns, 0 vs 2 allocs) - Insertions: 20x faster (976ns vs 19,191ns) - Large tables: 14x faster (5.2ns vs 74.85ns) * docs: clarify CHANGELOG to not give false impressions Signed-off-by: Jason Cameron <git@jasoncameron.dev> * perf: optimize string concatenation in RemoteAddrChecker hash generation Replace fmt.Fprintln with strings.Join for 7x faster performance: - Before: 935.1 ns/op, 784 B/op, 22 allocs/op - After: 133.2 ns/op, 192 B/op, 1 alloc/op The hash is used for JWT cookie validation and error code generation. Comma separation provides the same deterministic uniqueness as newlines but with significantly better performance during policy initialization. * chore: remove accidentally commited string benchmark Signed-off-by: Jason Cameron <git@jasoncameron.dev> * style: apply Copilot suggestions Signed-off-by: Jason Cameron <git@jasoncameron.dev> * fix: reference the right var name i cannot write a merge commit Signed-off-by: Jason Cameron <git@jasoncameron.dev> --------- Signed-off-by: Jason Cameron <git@jasoncameron.dev>
This commit is contained in:
parent
e2b46fc5e7
commit
b2b2679bae
9 changed files with 60 additions and 39 deletions
2
go.sum
2
go.sum
|
|
@ -286,8 +286,6 @@ github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM
|
|||
github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw=
|
||||
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 h1:nIPpBwaJSVYIxUFsDv3M8ofmx9yWTog9BfvIu0q41lo=
|
||||
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8/go.mod h1:HUYIGzjTL3rfEspMxjDjgmT5uz5wzYJKVo23qUhYTos=
|
||||
github.com/yl2chen/cidranger v1.0.2 h1:lbOWZVCG1tCRX4u24kuM1Tb4nHqWkDxwLdoS+SevawU=
|
||||
github.com/yl2chen/cidranger v1.0.2/go.mod h1:9U1yz7WPYDwf0vpNWFaeRh0bjwz5RVgRy/9UEQfHl0g=
|
||||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||
gitlab.com/digitalxero/go-conventional-commit v1.0.7 h1:8/dO6WWG+98PMhlZowt/YjuiKhqhGlOCwlIV8SqqGh8=
|
||||
gitlab.com/digitalxero/go-conventional-commit v1.0.7/go.mod h1:05Xc2BFsSyC5tKhK0y+P3bs0AwUtNuTp+mTpbCU/DZ0=
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue