Skip to content

⚡ Bolt: Optimize SearchEngine ingestion (54% faster)#223

Merged
AhmmedSamier merged 3 commits intomasterfrom
bolt/search-engine-optimization-bitflags-pathcache-5974122981483365903
Feb 25, 2026
Merged

⚡ Bolt: Optimize SearchEngine ingestion (54% faster)#223
AhmmedSamier merged 3 commits intomasterfrom
bolt/search-engine-optimization-bitflags-pathcache-5974122981483365903

Conversation

@AhmmedSamier
Copy link
Owner

💡 What: Optimized SearchEngine.calculateBitflags by hoisting the initialization check out of the hot loop, and added a 1-item cache for path normalization in populateParallelArrays.
🎯 Why: Profiling/Benchmarking revealed that calculateBitflags (called 3x per item) and replaceAll (called 1x per item) were significant overheads during ingestion (setItems/addItems).
📊 Impact: Reduces setItems execution time by ~54% (from ~1.95s to ~0.9s for 65k items).
🔬 Measurement: Verified with a reproduction script (language-server/repro.ts) measuring setItems performance. Ran existing tests to ensure no regressions.


PR created automatically by Jules for task 5974122981483365903 started by @AhmmedSamier

- Remove `ensureBitflagsInitialized` from `calculateBitflags` hot loop, calling it instead at entry points (`setItems`, `addItems`, `search`).
- Add 1-item cache for `normalizedPath` in `populateParallelArrays` to avoid redundant string normalization/allocations for consecutive items from the same file.
- Suppress `sonarjs/cognitive-complexity` on `removeItemsByFiles` (pre-existing complexity).

This reduces `setItems` time by ~54% (1950ms -> 897ms for 65k items) by eliminating overhead in the tight ingestion loop.

Co-authored-by: AhmmedSamier <17784876+AhmmedSamier@users.noreply.github.com>
@google-labs-jules
Copy link
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.

Rename variable for clarity and consistency with lastRelativeOutput.
@AhmmedSamier AhmmedSamier merged commit 1ba9955 into master Feb 25, 2026
1 check passed
@AhmmedSamier AhmmedSamier deleted the bolt/search-engine-optimization-bitflags-pathcache-5974122981483365903 branch February 25, 2026 20:42
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