Uh oh!
There was an error while loading. Please reload this page.
perf: compile regex patterns once instead of per-call in hot paths - #1098
perf: compile regex patterns once instead of per-call in hot paths#1098myukitty wants to merge 1 commit into
Conversation
Signed-off-by: myukitty <myukittyy@gmail.com>
d65036d to
992d010CompareHi @myukitty and thanks for your contribution. Checking this PR and comparing to the issue intent it has some shortcomings, which we'll address holistically with a fresh PR: #1114 Summary:5c ValidateDigest ✅ Correct, and thoughtfully done |
myukitty
commented
Aug 21, 2026
Thanks for writing that up rather than just closing it, @mbevc1 — the assessment is fair on both counts. On 5b you're right, and it's the more useful correction: I added On 5a, hoisting the compile out of the per-name loop also moves when an invalid pattern surfaces. That's a behaviour change, and it belonged in the description as one instead of riding along inside a perf change — #1114's note on preserving the original error timing is exactly the part I skipped. Handling it holistically in #1114 makes sense. Thanks for the review. |
When processing filters, Git commits, and Jira issue keys in loops or hot paths, compiling regular expressions on every iteration introduced unnecessary CPU and memory allocation overhead.
This PR:
ResourceFilterOptions: Lazily compiles and caches include/exclude regexes usingsync.Once, making concurrentShouldIncludecalls thread-safe and fast.GitView: AddsMatchRegexpInCommitMessageORBranchName(re *regexp.Regexp, ...)accepting a precompiled regex while maintaining backward-compatibleMatchPatternInCommitMessageORBranchName(pattern, ...).Jira: Pre-compiles and caches Jira key patterns in a thread-safesync.Map(getJiraKeyRegex) so both default and custom project key patterns avoid per-call compilation inFindJiraIssueKeys.internal/filters/resourceFilter_test.go,internal/jira/jira_test.go, andinternal/gitview/gitView_test.go.Fixes#826.