Repository navigation
Conversation
Namespace filtering invokes regexp.MatchString with the same rule strings for each namespace, recompiling unchanged expressions on the hot path. Compile whitelist and blacklist rules once per filter and reuse them. Preserve empty and malformed-pattern behavior, rule precedence and special namespace handling. Add compatibility tests and benchmarks. Co-Authored-By: OpenAI Codex <noreply@openai.com> AI-Model: gpt-6.2-sol AI-Contributed/Feature: 25/25 AI-Contributed/UT: 81/81
|
Reviewed EquivalenceThe entire semantic surface of the change is I re-implemented the develop version of That probe only exercises the unexported rule layer, which leaves the The white/black error asymmetry is preserved correctly: invalid whitelist filters everything, invalid blacklist filters nothing, and Test sensitivity
ConcurrencyProduction shares a single Minor, non-blocking: the new table never uses more than one ruleAll 22 cases pass a single-element (or empty) slice, so the alternation grouping that
{name: "multi rule exact match", white: []string{"gogo.test1", "gogo.test2"}, namespace: "gogo.test2"},
{name: "multi rule prefix boundary", white: []string{"gogo.test1", "gogo.test2"}, namespace: "gogo.test1X", filtered: true},
{name: "multi rule prefix match", white: []string{"gogo.test1", "gogo.test2"}, namespace: "gogo.test2.archive"},
{name: "multi rule black boundary", black: []string{"gogo.test1", "gogo.test2"}, namespace: "gogo.test2X"},I ran these four rows on your branch: all pass, and the Verified locally
|
|
Thank you for your contribution—excellent work! |
Summary
Namespace filtering currently calls
regexp.MatchStringwith the same generated rule strings for every namespace. This recompiles the regular expressions on the hot path, including when a large number of oplog records belong to namespaces outside the configured filter.NamespaceFilterand reuse the compiled expressions.Benchmark
Go 1.27.3, darwin/arm64, Apple M4. Same benchmark on the develop baseline and this change; medians of three runs per case:
Compiled-rule initialization is outside the timed loop. The figures measure individual
FilterNscalls with synthetic namespaces, not end-to-end replication throughput.Validation
TestNamespaceFilterRuleMatchingpasses on both the original and optimized implementation.go build ./...); all tracked Go files are gofmt-clean.collector/configure,collector/filter,collector/transform,collector/spool.go test -race ./collector/filter -count=1passes.