Skip to content

Conversation

@madumas
Copy link

@madumas madumas commented Dec 5, 2025

Replace repeated Array.filter() + Array.find() with Map-based lookup for deployment rules.

  • Add preprocessRules() function to create Map for O(1) rule lookups
  • Update isDeploymentWorthAllocatingTowards() to use pre-processed rules Map
  • Update evaluateDeployments() to preprocess rules once instead of per deployment
  • Update AllocationManager.matchingRuleExists() to use optimized lookup

Performance improvement:

  • Before: O(n²) - filter + find for each deployment evaluation
  • After: O(n) - single preprocessing + O(1) lookups per deployment
  • Significant speedup when evaluating many deployments against many rules

Fixes performance bottleneck in allocation rule evaluation where processing thousands of deployments with hundreds of rules resulted in quadratic complexity.

@github-project-automation github-project-automation bot moved this to 🗃️ Inbox in Indexer Dec 5, 2025
@madumas madumas force-pushed the perf/optimize-allocation-rules branch from 72bfa9b to b87eeb2 Compare December 5, 2025 14:18
Replace repeated Array.filter() + Array.find() with Map-based lookup for deployment rules.

- Add preprocessRules() function to create Map for O(1) rule lookups
- Update isDeploymentWorthAllocatingTowards() to use pre-processed rules Map
- Update evaluateDeployments() to preprocess rules once instead of per deployment
- Update AllocationManager.matchingRuleExists() to use optimized lookup

Performance improvement:
- Before: O(n²) - filter + find for each deployment evaluation
- After: O(n) - single preprocessing + O(1) lookups per deployment
- Significant speedup when evaluating many deployments against many rules

Fixes performance bottleneck in allocation rule evaluation where processing
thousands of deployments with hundreds of rules resulted in quadratic complexity.
@madumas madumas force-pushed the perf/optimize-allocation-rules branch from b87eeb2 to 2618f23 Compare December 5, 2025 14:23
@madumas madumas marked this pull request as ready for review December 5, 2025 16:45
dwerner added a commit that referenced this pull request Dec 5, 2025
Replace repeated Array.filter() and Array.find() operations with a
Map-based lookup system for deployment rules.

Changes:
- Add preprocessRules() function to create a Map for O(1) rule lookups
- Update isDeploymentWorthAllocatingTowards() to use preprocessed rules
- Update evaluateDeployments() to preprocess rules once before iteration
- Update matchingRuleExists() in AllocationManager to use optimized lookup

This eliminates quadratic complexity when evaluating thousands of
deployments against hundreds of rules.

Based on: #1147
Original author: madumas
Original commit: 2618f23
@dwerner
Copy link
Contributor

dwerner commented Dec 5, 2025

pulled in #1149

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.

2 participants