⚡ Bolt: Optimize array operations in ticker discovery - #133
Conversation
- Removed `.map()` and `.slice()` allocations in `buildCandidate` by directly indexing `bars` from the end. - Rewrote `recentVol` and `priorVol` array `.reduce()` chains into simple `for` loops. - Replaced `.filter().map()` chains with in-place mutation and standard `for` loops in `discoverTickers` to avoid memory allocation overhead during strategy scans. - Updated `rsi14` signature to accept the raw bar objects instead of mapped arrays, calculating gains/losses via negative indexing. Co-authored-by: toreleon <42534763+toreleon@users.noreply.github.com>
|
👋 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. |
- Bumped the `undici` override in `package.json` to `>=7.29.0 <8.0.0` to address GHSA-4cwx-7wf7-3272 and ensure CI dependency audit checks pass. - Verified test suite passes locally. Co-authored-by: toreleon <42534763+toreleon@users.noreply.github.com>
💡 What: Refactored array operations in the
discoverTickersandbuildCandidatefunctions to avoid creating intermediate arrays (via.map,.slice,.filter, and.reduce) and to eliminate unnecessary object spreading. Code now directly indexes arrays from the end and mutates fresh objects in place before sorting.🎯 Why: The ticker discovery tool processes hundreds of tickers and iterates through chronological arrays to extract recent metrics. Chaining operations like
.map().slice().reduce()in these loops creates heavy garbage collection overhead and continuous memory allocation pauses in Node/V8.📊 Impact: Reduces memory allocation during discovery scans significantly, leading to faster ticker scoring.
🔬 Measurement: Verified the logic maintains exact correctness by passing
pnpm test tests/discover.test.tsand the mainpnpm testsuite. Checked TypeScript compilation viapnpm typecheck.PR created automatically by Jules for task 6502714416141036385 started by @toreleon