Skip to content

⚡ Bolt: Optimize candidate subset extraction in backtest hot loop - #173

Merged
toreleon merged 1 commit into
masterfrom
bolt/optimize-hot-loop-subset-3183424267232562118
Oct 7, 2026
Merged

toreleon merged 1 commit into
masterfrom
bolt/optimize-hot-loop-subset-3183424267232562118

Conversation

@toreleon

@toreleon toreleon commented Oct 4, 2026

Copy link
Copy Markdown
Owner

💡 What: Replaced an expensive array-to-Set-to-array method chain (Array.from(new Set([...held, ...discovery.candidates.map(c => c.ticker)])).slice(0, N)) with bounded for loops and a dedicated Set for duplicate tracking.
🎯 Why: The previous approach allocated multiple intermediate arrays and iterated over the entire candidate list on every tick of a backtest session, generating significant garbage collection overhead.
📊 Impact: Reduces memory allocations in the main backtest simulation loop, leading to faster execution times for multi-month backtest runs, with fewer allocations per turn.
🔬 Measurement: Verify tests run successfully using pnpm test and types pass with pnpm typecheck. Inspect the loop logic in src/agent/backtestRunner.ts to see that it processes elements lazy and exits early.


PR created automatically by Jules for task 3183424267232562118 started by @toreleon

@google-labs-jules

Copy link
Copy Markdown
Contributor

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

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

…loop

Replaces array method chaining (`.map()`, spread operator, `new Set()`, `Array.from()`, `.slice()`) with bounded `for` loops in the backtest turn loop to avoid generating multiple intermediate arrays and creating unnecessary GC pressure.

Co-authored-by: toreleon <42534763+toreleon@users.noreply.github.com>
@toreleon
toreleon force-pushed the bolt/optimize-hot-loop-subset-3183424267232562118 branch from 42901f4 to ffe5feb Compare October 7, 2026 07:04
@toreleon
toreleon merged commit 3490cdd into master Oct 7, 2026
4 checks passed
@toreleon
toreleon deleted the bolt/optimize-hot-loop-subset-3183424267232562118 branch October 7, 2026 07:08
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.

1 participant