Skip to content

⚡ Bolt: Optimize array operations in ticker discovery - #133

Draft
toreleon wants to merge 2 commits into
masterfrom
bolt-optimize-discover-array-ops-6502714416141036385
Draft

⚡ Bolt: Optimize array operations in ticker discovery#133
toreleon wants to merge 2 commits into
masterfrom
bolt-optimize-discover-array-ops-6502714416141036385

Conversation

@toreleon

Copy link
Copy Markdown
Owner

💡 What: Refactored array operations in the discoverTickers and buildCandidate functions 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.ts and the main pnpm test suite. Checked TypeScript compilation via pnpm typecheck.


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

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

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