mirror of
https://github.com/wweir/sower.git
synced 2026-10-20 00:15:34 +00:00
- countingConn batches per-domain attribution (32KiB/500ms) so the relay hot path pays two atomics per I/O instead of a global mutex; Close drains - Precompute OTel byte attributes to drop per-I/O allocations - suffixtree: indexMap only for nodes with >=8 children; Match stays read-only for concurrent queries - Soft Go memory limit (128MiB default, GOMEMLIMIT/SOWER_MEMORY_LIMIT_MB override) cuts resident memory from ~240MB to ~130MB on the default ad/china/gfw rule sets - Split stats.go into snapshot/eviction/counting by responsibility
35 lines
631 B
Go
35 lines
631 B
Go
package router
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
)
|
|
|
|
func BenchmarkRuleSetMatch(b *testing.B) {
|
|
rules := make([]string, 0, 10000)
|
|
for i := 0; i < 10000; i++ {
|
|
rules = append(rules, fmt.Sprintf("host%d.example.com", i))
|
|
}
|
|
rs := NewRuleSet(rules...)
|
|
|
|
b.ReportAllocs()
|
|
b.ResetTimer()
|
|
for range b.N {
|
|
rs.Match("www.example.com")
|
|
}
|
|
}
|
|
|
|
func BenchmarkRuleSetMatchHit(b *testing.B) {
|
|
rules := make([]string, 0, 10000)
|
|
for i := 0; i < 10000; i++ {
|
|
rules = append(rules, fmt.Sprintf("host%d.example.com", i))
|
|
}
|
|
rs := NewRuleSet(rules...)
|
|
|
|
b.ReportAllocs()
|
|
b.ResetTimer()
|
|
for range b.N {
|
|
rs.Match("host5000.example.com")
|
|
}
|
|
}
|