Aias00 opened a new issue, #6564: URL: https://github.com/apache/shenyu/issues/6564
## Description The three predicate judges invoked from `PredicateJudgeFactory.judge` (once per condition per rule/selector per request, on cache miss) compile/parse their pattern fresh on every call. `RegexPredicateJudge` calls `com.google.re2j.Pattern.matches(regex, input)` (no compiled-pattern cache); `PathPatternPredicateJudge` calls `PathPatternParser.defaultInstance.parse(...)` per call; `MatchPredicateJudge` runs `AntPathMatcher.doMatch` which builds an `AntPathStringMatcher` (compiling a `java.util.regex.Pattern`) per call when `cacheToPatternThreshold=0` (default). The L1 `MatchDataCache` only short-circuits rules whose conditions are all `uri`-type, so any rule mixing header/query/cookie conditions pays the full compile cost every request. ## Location ``` shenyu-plugin-base/.../condition/judge/RegexPredicateJudge.java:33 PathPatternPredicateJudge.java:39 -> PathMatchUtils.java:66 MatchPredicateJudge.java:36 -> PathMatchUtils.java:54-55 ``` ## Impact `req/s x (#regex/pathPattern/match conditions in matched rules)` pattern compiles per second. A rule with 3 such conditions at 10k req/s = 30k compiles/s of CPU on the Netty event loop. Regex compilation is the dominant per-request CPU cost on the match path for non-URI-only rules. ## Suggested fix Cache a compiled `Pattern`/`PathPattern` keyed by the condition's `paramValue` (bounded Caffeine, or precompile at rule-sync time and store the compiled pattern on `ConditionData`). For `AntPathMatcher`, enable `setCachePatterns(true)` or migrate URI matching to `PathPattern`. ## Related existing issue(s) #6404 is about regex timeout protection, not compilation cost — distinct. _Identified during the 2026-08-02 audit; full list in [`docs/issue-candidates-2026-08-02.md`](docs/issue-candidates-2026-08-02.md)._ -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
