perf: compile remote match patterns once instead of per-request #88
Reference in New Issue
Block a user
Delete Branch "benvin/compile-patterns-once"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixes #73
Why
Classifier.Classifyruns on every proxied request and recompiled the Blocklist/Patterns/Immutable/Mutable regex lists each time. Regex compilation is expensive and fully redundant.Changes
sync.Mapkeyed by pattern text (compileCached); each distinct pattern compiles once and is reused. Patterns that fail to compile are cached as a typed nil so they are not retried. No invalidation needed since the pattern text is the key.Validation
go test ./internal/proxy/andmake e2epass.