Repository navigation
⚡ Bolt: Optimize candidate subset extraction in backtest hot loop - #173
Conversation
|
👋 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 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 reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
…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>
42901f4 to
ffe5feb
Compare
💡 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 boundedforloops and a dedicatedSetfor 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 testand types pass withpnpm typecheck. Inspect the loop logic insrc/agent/backtestRunner.tsto see that it processes elements lazy and exits early.PR created automatically by Jules for task 3183424267232562118 started by @toreleon