Skip to content

common: rule preprocessing for performance #1114

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

madumas
Copy link

@madumas madumas commented Apr 17, 2025

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:

  • Implemented Map-based rule lookup for O(1) access to deployment rules
  • Added caching of global rule to avoid repeated searches
  • Introduced PreprocessedRules interface to maintain type safety
  • Optimized both evaluateDeployments and matchingRuleExists to use the new lookup system

This 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.

@github-project-automation github-project-automation bot moved this to 🗃️ Inbox in Indexer Apr 17, 2025
@madumas madumas changed the title common: rule processing for performance common: rule preprocessing for performance Apr 17, 2025
@madumas madumas changed the base branch from release-v0.22.1 to main April 17, 2025 20:34
@madumas madumas changed the base branch from main to release-v0.22.1 April 17, 2025 20:35
@madumas madumas changed the base branch from release-v0.22.1 to main April 17, 2025 20:57
@madumas madumas marked this pull request as ready for review April 17, 2025 21:05
@madumas
Copy link
Author

madumas commented Apr 17, 2025

CI jobs appear to be failing due to permissions or because I'm outside the org

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 🗃️ Inbox
Development

Successfully merging this pull request may close these issues.

1 participant