Skip to content

⚡ Bolt: Optimize backtest candidate deduplication loop - #168

Closed
toreleon wants to merge 1 commit into
masterfrom
bolt-optimize-backtest-deduplication-11300147719612583135
Closed

toreleon wants to merge 1 commit into
masterfrom
bolt-optimize-backtest-deduplication-11300147719612583135

Conversation

@toreleon

Copy link
Copy Markdown
Owner

💡 What: Replaced a heavy functional pipeline (chain of .map(), array spreading, new Set(), Array.from(), and .slice()) with bounded for loops and an early-exit Set during candidate deduplication in the backtest runner.
🎯 Why: High-frequency backtesting engines suffer when allocating large intermediate arrays inside hot loops. This process was needlessly spreading entire sets of positions and candidates into temporary arrays just to slice a tiny subset off the end.
📊 Impact: Eliminates three intermediate array allocations per iteration and stops looping once the required maxCandidates threshold is met, reducing GC overhead and memory churn.
🔬 Measurement: Verify by running the test suite (pnpm test) and observing backtest speed.


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

💡 What: Replaced a heavy chain of `.map()`, array spreading, `new Set()`, `Array.from()`, and `.slice()` with bounded `for` loops in the backtest runner.
🎯 Why: High-frequency backtesting engines suffer when allocating large intermediate arrays inside hot loops, creating significant garbage collection (GC) overhead.
📊 Impact: Eliminates three intermediate array allocations and truncates iteration early if the max candidate count is reached, saving memory overhead in each step of the backtest loop.
🔬 Measurement: Verify via backtest run performance and `pnpm test`.

Co-authored-by: toreleon <42534763+toreleon@users.noreply.github.com>
@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.

@toreleon

toreleon commented Oct 7, 2026

Copy link
Copy Markdown
Owner Author

Closed in favor of #173.

@toreleon toreleon closed this Oct 7, 2026
@toreleon
toreleon deleted the bolt-optimize-backtest-deduplication-11300147719612583135 branch October 7, 2026 06:05
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