Skip to content

⚡ Bolt: Optimize array allocations in discover tool - #110

Draft
toreleon wants to merge 11 commits into
masterfrom
bolt-optimize-discover-allocations-11703465256289938067
Draft

⚡ Bolt: Optimize array allocations in discover tool#110
toreleon wants to merge 11 commits into
masterfrom
bolt-optimize-discover-allocations-11703465256289938067

Conversation

@toreleon

@toreleon toreleon commented Aug 6, 2026

Copy link
Copy Markdown
Owner

💡 What:
Eliminated .map(), .slice(), and .reduce() allocations in buildCandidate and rsi14 functions in src/tools/discover.ts. Replaced them with direct indexed for loops that operate in-place on the source bars array.

🎯 Why:
During ticker discovery (discoverTickers), the system iterates over potentially hundreds of stock candidates, pulling recent OHLCV bars for each. The previous implementation mapped the bars array into temporary closes and vols arrays, then used .slice to create subsets, and .reduce to sum values. This created significant, unnecessary memory allocation and garbage collection churn in a hot path.

📊 Impact:
Significantly reduces transient memory pressure and GC pauses during ticker discovery sweeps by operating directly on the fetched time-series data without intermediate array copies.

🔬 Measurement:
Run pnpm test tests/discover.test.ts and pnpm typecheck to verify the logic is perfectly preserved and no tests are failing.


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

Eliminates memory allocation and garbage collection overhead in the ticker
discovery hot path by removing chaining array methods (`.map`, `.slice`, `.reduce`).
Metrics computation now uses direct indexed `for` loops on the source `bars` array.
The `rsi14` function was updated to accept the `bars` array directly instead of a mapped
array of primitive numbers.

These changes prevent allocating and collecting O(N) temporary arrays for hundreds
of candidates on each scan.

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.

google-labs-jules Bot and others added 10 commits August 6, 2026 15:51
Resolves a high-severity vulnerability in the `undici` dependency related
to cross-user information disclosure and parse-time crashes via degenerate
private cache directives. This is caught by the `pnpm audit` CI check.

Co-authored-by: toreleon <42534763+toreleon@users.noreply.github.com>
Resolves a high-severity vulnerability in the `undici` dependency related
to cross-user information disclosure and parse-time crashes via degenerate
private cache directives. This is caught by the `pnpm audit` CI check.

Co-authored-by: toreleon <42534763+toreleon@users.noreply.github.com>
Resolves a high-severity vulnerability in the `undici` dependency related
to cross-user information disclosure and parse-time crashes via degenerate
private cache directives. This is caught by the `pnpm audit` CI check.

Co-authored-by: toreleon <42534763+toreleon@users.noreply.github.com>
Resolves a high-severity vulnerability in the `undici` dependency related
to cross-user information disclosure and parse-time crashes via degenerate
private cache directives. This is caught by the `pnpm audit` CI check.

Co-authored-by: toreleon <42534763+toreleon@users.noreply.github.com>
Resolves a high-severity vulnerability in the `undici` dependency related
to cross-user information disclosure and parse-time crashes via degenerate
private cache directives. This is caught by the `pnpm audit` CI check.

Co-authored-by: toreleon <42534763+toreleon@users.noreply.github.com>
Resolves a high-severity vulnerability in the `undici` dependency related
to cross-user information disclosure and parse-time crashes via degenerate
private cache directives. This is caught by the `pnpm audit` CI check.

Co-authored-by: toreleon <42534763+toreleon@users.noreply.github.com>
Resolves a high-severity vulnerability in the `undici` dependency related
to cross-user information disclosure and parse-time crashes via degenerate
private cache directives. This is caught by the `pnpm audit` CI check.

Co-authored-by: toreleon <42534763+toreleon@users.noreply.github.com>
Resolves a high-severity vulnerability in the `undici` dependency related
to cross-user information disclosure and parse-time crashes via degenerate
private cache directives. This is caught by the `pnpm audit` CI check.

Co-authored-by: toreleon <42534763+toreleon@users.noreply.github.com>
Resolves a high-severity vulnerability in the `undici` dependency related
to cross-user information disclosure and parse-time crashes via degenerate
private cache directives. This is caught by the `pnpm audit` CI check.

Co-authored-by: toreleon <42534763+toreleon@users.noreply.github.com>
Resolves a high-severity vulnerability in the `undici` dependency related
to cross-user information disclosure and parse-time crashes via degenerate
private cache directives. This is caught by the `pnpm audit` CI check.

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