Repository navigation
Conversation
Tool.snapshot calls Wildcard.match once per tool and permission rule on every provider step. Each call compiled a new RegExp; the profiling in anomalyco#63099 showed this at 24-32% of service CPU. Cache compiled patterns by source string, with a bounded FIFO so an unusual rule set cannot grow the cache without limit. Fixes anomalyco#63099
Contributor
|
Thanks for the fix, and for the benchmark numbers on #63099! I think this duplicates #55322, which already proposes the same change: it caches compiled regexes in If that pull request is missing something, for example your 1,200 tools × 60 rules benchmark or the link to #63099, a review, test results or a comment there would be very welcome. |
3 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Closes #63099
Type of change
What does this PR do?
Tool.snapshotcallsWildcard.matchonce per tool and permission rule on every provider step. Each call compiled a newRegExp; #63099 profiled this at 24–32% of service CPU. This caches compiled patterns by source string with a bounded FIFO (1024), so a large rule set cannot grow the cache without limit.AI assistance: used to help draft the patch; I reviewed the diff and ran the verification below.
How did you verify your code works?
packages/core/test/wildcard.test.ts: 6 pass, 0 fail;packages/core/test/permission.test.ts: 122 pass, 0 fail.bun run typecheckinpackages/core: no type errors (2,013 files / 2 projects).oxlintandprettier --checkon both changed files: clean.Visual
N/A — internal performance fix; no user-facing behavior change.
Checklist