common: rule preprocessing for performance #1114
Open
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.
This change significantly improves the performance of rule matching operations by implementing a Map-based lookup system. Previously, each deployment required a linear search through all rules, resulting in O(n*m) complexity for n deployments and m rules.
Key changes:
PreprocessedRules
interface to maintain type safetyevaluateDeployments
andmatchingRuleExists
to use the new lookup systemThis optimization is particularly impactful for large rule sets, reducing the complexity from O(n*m) to O(n) where n is the number of deployments. For example, with 800 rules and 15,000 deployments, the number of operations is reduced from approximately 12 million to 15,000.