ai-code-battle/cmd/acb-index-builder
jedarden 7befe516bf fix(db): eliminate O(n²) iteration in generateBotProfiles
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.
2026-06-25 01:29:26 -04:00
..
blog.go style: apply gofmt alignment fixes across codebase 2026-05-24 10:40:33 -04:00
cards.go Implement S3 functions for R2/B2 integration in acb-index-builder 2026-03-29 09:09:29 -04:00
config.go style: apply gofmt alignment fixes across codebase 2026-05-24 10:40:33 -04:00
db.go fix(db): add LIMIT to unbounded queries causing OOMKill 2026-06-25 01:29:26 -04:00
deploy.go fix(db): add LIMITs to unbounded queries to prevent OOM 2026-06-25 00:38:55 -04:00
Dockerfile fix(index-builder): run wrangler from /app/web to pick up functions/ bundle 2026-04-30 12:39:57 -04:00
enrichment.go style: apply gofmt alignment fixes across codebase 2026-05-24 10:40:33 -04:00
enrichment_test.go fix(index-builder): correct series/season exempt queries, optimize playlist curation 2026-04-21 16:47:13 -04:00
generator.go fix(db): eliminate O(n²) iteration in generateBotProfiles 2026-06-25 01:29:26 -04:00
main.go Revert "fix(index-builder): promote recent replays from B2 to R2 warm cache" 2026-05-26 16:33:19 -04:00
main_test.go feat(index-builder): generate data/meta/index.json 2026-05-26 13:08:17 -04:00
narrative.go style: apply gofmt alignment fixes across codebase 2026-05-24 10:40:33 -04:00
narrative_test.go style: apply gofmt alignment fixes across codebase 2026-05-24 10:40:33 -04:00
rivalry_test.go style: apply gofmt alignment fixes across codebase 2026-05-24 10:40:33 -04:00
s3.go style: apply gofmt alignment fixes across codebase 2026-05-24 10:40:33 -04:00
s3_test.go docs(plan): update ZoneShrinkStep from 2 to 1 to match implementation 2026-05-26 08:22:27 -04:00
sitebuild.go fix(types): add missing ReplayPlayer import and type annotation for transcript feature 2026-04-22 18:20:56 -04:00
sitebuild_test.go fix(types): add missing ReplayPlayer import and type annotation for transcript feature 2026-04-22 18:20:56 -04:00