Skip to content

⚡ Bolt: [performance improvement]#423

Open
AhmmedSamier wants to merge 1 commit intomasterfrom
bolt-eliminate-allocation-2058310595245264707
Open

⚡ Bolt: [performance improvement]#423
AhmmedSamier wants to merge 1 commit intomasterfrom
bolt-eliminate-allocation-2058310595245264707

Conversation

@AhmmedSamier
Copy link
Copy Markdown
Owner

@AhmmedSamier AhmmedSamier commented May 9, 2026

💡 What
Replaced the searchedIndices Uint8Array tracker array allocation in SearchEngine.searchRemainingItems with an O(1) scope check using the pre-existing this.itemTypeIds and ID_TO_SCOPE arrays.

🎯 Why
When searchRemainingItems is invoked as the final fallback pass in a burst search, it previously allocated an O(N) Uint8Array based on the total number of items, looping through the priority scopes to mark visited items before checking the array against the remaining items. By replacing this explicit tracking with an inherent check (!priorityScopes.includes(ID_TO_SCOPE[this.itemTypeIds[i]])), we completely eliminate the memory allocation, initialization overhead, and garbage collection pressure in this hot path.

📊 Impact
Reduces average tail latency for full fallback searches (where no matches are found in priority scopes) by ~40% (from ~30ms to ~18ms), by eliminating the O(N) object allocation overhead and reducing the total iterations required before executing the main search loop.

🔬 Measurement
Verify the improvement by running the dedicated burst search benchmark via cd language-server && bun run benchmarks/search_burst.bench.ts and observing the 'Zzz (No match)' results.


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

Summary by CodeRabbit

  • Performance

    • Search engine performance improved through optimization of multi-pass search operations, resulting in faster query execution and reduced computational overhead.
  • Documentation

    • Added documentation and performance benchmarks for search optimization improvements.

Review Change Stack

…ainingItems

Replaced the `searchedIndices` Uint8Array tracker allocation in `searchRemainingItems` with an O(1) condition check using `this.itemTypeIds` and `ID_TO_SCOPE` to determine if an item belongs to the priority scopes. This removes the memory allocation, O(N) zero-fill overhead, and GC pressure during the final fallback search phase.

Co-authored-by: AhmmedSamier <17784876+AhmmedSamier@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.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 9, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d524baa6-9739-4a82-a56f-896e31993041

📥 Commits

Reviewing files that changed from the base of the PR and between 2ab42b0 and 7f0c8b9.

📒 Files selected for processing (3)
  • .jules/bolt.md
  • language-server/benchmarks/results_burst.json
  • language-server/src/core/search-engine.ts

📝 Walkthrough

Walkthrough

SearchEngine.burstSearch is optimized by eliminating per-query Uint8Array visited tracking. The searchRemainingItems logic now filters candidates inline by checking item scopes against priorityScopes, replacing a two-phase approach with O(1) scope-membership verification using existing ID_TO_SCOPE metadata.

Changes

Burst Search Optimization

Layer / File(s) Summary
Optimization Notes
.jules/bolt.md
Changelog entry (2026-05-06) documents removal of O(N) visited-tracking array and initialization pass, replaced with O(1) scope-membership checks.
Core Logic Update
language-server/src/core/search-engine.ts
searchRemainingItems removes searchedIndices Uint8Array and filters candidates by checking each item's inherent scope via ID_TO_SCOPE against priorityScopes, skipping already-processed scopes.
Benchmark Measurements
language-server/benchmarks/results_burst.json
New JSON results file records three Burst Search scenarios with timing metrics: average, total, min/max, p95, and standard deviation.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • AhmmedSamier/DeepLens#344: PR #344 introduced the Uint8Array-based visited tracker that this PR now removes, replacing it with scope-based O(1) checks.
  • AhmmedSamier/DeepLens#253: PR #253 restructured burstSearch to collect/rank all candidates, while this PR optimizes the per-scope deduplication mechanism within searchRemainingItems.
  • AhmmedSamier/DeepLens#333: PR #333 applies related single-pass, scope-based filtering changes in SearchEngine to remove extra passes and allocations.

Suggested labels

codex

Poem

🐰 Arrays once tracked what scopes had passed,
O(N) overhead, heavy and vast—
Now scope checks bloom with O(1) grace,
Metadata lookups win the race! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title uses vague placeholder language '[performance improvement]' that doesn't convey the specific change; while it mentions the Bolt project and performance, it lacks clarity about the actual optimization. Replace '[performance improvement]' with specific details like 'eliminates Uint8Array allocation in searchRemainingItems' or 'replaces O(N) visited-tracking with O(1) scope check'.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch bolt-eliminate-allocation-2058310595245264707

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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