The generateBotProfiles function had two nested loops that caused O(n²) memory usage:
- Iterating through all rating history entries (10,000) for each bot (10,000) = 100M iterations
- Iterating through all matches (1,000) for each bot (10,000) = 10M iterations
This caused acb-index-builder to run out of memory and get OOMKilled during the build cycle.
Fixed by pre-building lookup maps (O(n) build + O(1) lookup):
- historyMap[botID] -> []RatingHistoryEntry
- matchMap[botID] -> []MatchSummary
Reduces complexity from O(bots × matches) to O(matches + bots) for lookups.
Resolves acb-index-builder CrashLoopBackOff after 45 days of failure.