Skip to content

⚡ Bolt: Replace intermediate array allocations with pre-allocated tracking arrays in group creation loops#572

Open
google-labs-jules[bot] wants to merge 2 commits into
mainfrom
bolt-optimize-group-creation-arrays-14854395974282579551
Open

⚡ Bolt: Replace intermediate array allocations with pre-allocated tracking arrays in group creation loops#572
google-labs-jules[bot] wants to merge 2 commits into
mainfrom
bolt-optimize-group-creation-arrays-14854395974282579551

Conversation

@google-labs-jules

Copy link
Copy Markdown
Contributor

💡 What: Eliminated all dynamic array allocations in the hot loops inside packages/shared/src/parallelGroupCreator.ts. Replaced group.players getter calls with zero-allocation module-level bounded tracking arrays (e.g. const _giPlayers = new Array(5)).

🎯 Why: The algorithm repeatedly evaluates thousands of group permutations during the diversifyGroups simulated annealing pass (trySingleSwap and tryThreeCycle). Accessing group.players generated a new array on every inner loop iteration, causing heavy garbage collection pauses and slowing down CPU-bound combinatorics scaling with large player counts.

📊 Impact: Substantially reduces object instantiation and garbage collection overhead during group creation by eliminating the allocation of millions of short-lived arrays per spin. Improves overall processing speed and responsiveness, especially at scale.

🔬 Measurement:

  • Run npm -w packages/bot run test -- tests/parallelGroupCreator.test.ts to ensure behavior remains identical.
  • In production, monitor the CPU execution duration of the createMythicPlusGroups call for maximum capacity 25-player runs.

PR created automatically by Jules for task 14854395974282579551 started by @TytaniumDev

… loops

Optimized hot loops in `parallelGroupCreator.ts` (`scoreGroups`, `trySingleSwap`, `tryThreeCycle`) by replacing dynamic array instantiations via the `group.players` getter with zero-allocation module-level scratchpad arrays (`_scorePlayers`, `_giPlayers`, etc.). Tracks lengths properly to avoid memory leaks. Eliminates millions of short-lived objects during simulated annealing loops.
@google-labs-jules

Copy link
Copy Markdown
Contributor Author

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Adds missing export for `SeasonPairs` type in `packages/shared/src/index.ts` to resolve Activity workspace typecheck failure on CI.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants