daemon: rule lists operators caching + lists matching enhancements#1567
Conversation
|
thanks @nvandamme , regarding glob matching, did you try using the functions from the standard lib Glob or Match? https://pkg.go.dev/path/filepath@go1.23.0#Match https://github.com/gobwas/glob has not been updated in 8 years and has several issues open. |
f1db396 to
e2b4af5
Compare
Done, dropped gobwas and relaced it with filepath.Match native go globbing. Some edge cases tough :
|
5013342 to
483b038
Compare
|
can you share your benchmarks @nvandamme ? I'm obtaining different results. RLock wins in all cases except for Regexp operations. opensnitch/rule $ go test -v -bench=. -benchmem -benchtime=10s -run=^$
goos: linux
goarch: amd64
pkg: github.com/evilsocket/opensnitch/daemon/rule
cpu: Intel(R) Core(TM) i7-3610QM CPU @ 2.30GHz
BenchmarkOperatorDomainsSnapshotMatchParallel
BenchmarkOperatorDomainsSnapshotMatchParallel-4 51280838 254.8 ns/op 112 B/op 4 allocs/op
BenchmarkOperatorDomainsSnapshotMixedParallel
BenchmarkOperatorDomainsSnapshotMixedParallel-4 58007008 224.7 ns/op 100 B/op 3 allocs/op
BenchmarkOperatorDomainsRLockMixedParallel
BenchmarkOperatorDomainsRLockMixedParallel-4 83306914 159.3 ns/op 49 B/op 1 allocs/op
BenchmarkOperatorIPSnapshotMixedParallel
BenchmarkOperatorIPSnapshotMixedParallel-4 53569580 222.5 ns/op 73 B/op 4 allocs/op
BenchmarkOperatorIPRLockMixedParallel
BenchmarkOperatorIPRLockMixedParallel-4 100000000 133.9 ns/op 14 B/op 1 allocs/op
BenchmarkOperatorNetSnapshotMixedParallel
BenchmarkOperatorNetSnapshotMixedParallel-4 50968135 230.9 ns/op 70 B/op 4 allocs/op
BenchmarkOperatorNetRLockMixedParallel
BenchmarkOperatorNetRLockMixedParallel-4 100000000 123.2 ns/op 14 B/op 1 allocs/op
BenchmarkOperatorDomainsRegexpSnapshotMixedParallel
BenchmarkOperatorDomainsRegexpSnapshotMixedParallel-4 22433817 574.1 ns/op 0 B/op 0 allocs/op
BenchmarkOperatorDomainsRegexpRLockMixedParallel
BenchmarkOperatorDomainsRegexpRLockMixedParallel-4 20802310 758.4 ns/op 0 B/op 0 allocs/op
BenchmarkLoaderFindFirstMatchSnapshotParallel
BenchmarkLoaderFindFirstMatchSnapshotParallel-4 23578188 445.3 ns/op 0 B/op 0 allocs/op |
|
Sure @gustavo-iniguez-goya, here you go: And on a laptop : |
|
Despite of my benchmark results, measuring reject rules matching using simple domain lists in FindFirstMatch() , there's a 3x improvement, from about ~450µs down to ~150µs. I'll update the wiki with the new features. Thanks @nvandamme ! |
This PR is a proposal to :
New comparison benchmarks added:
10s benchmem comparison:
Domains mixed
Snapshot: 27.33 ns/op
RLock: 61.54 ns/op
Snapshot is about 2.25x faster
IP mixed
Snapshot: 24.55 ns/op
RLock: 52.79 ns/op
Snapshot is about 2.15x faster
Nets mixed
Snapshot: 24.96 ns/op
RLock: 53.57 ns/op
Snapshot is about 2.15x faster
Domains regexp mixed
Snapshot: 33.77 ns/op
RLock: 48.47 ns/op
Snapshot is about 1.44x faster