Skip to content

⚡ Bolt: Optimize Remaining Scopes Iteration and Personalization#591

Open
AhmmedSamier wants to merge 1 commit into
masterfrom
perf-optimizations-15282753534866113965
Open

⚡ Bolt: Optimize Remaining Scopes Iteration and Personalization#591
AhmmedSamier wants to merge 1 commit into
masterfrom
perf-optimizations-15282753534866113965

Conversation

@AhmmedSamier

@AhmmedSamier AhmmedSamier commented Jul 21, 2026

Copy link
Copy Markdown
Owner

💡 What: Precomputed priority type array statically to avoid per-search allocation in searchRemainingItems. Extracted loop invariant 1 - activityWeight calculation in applyPersonalizedBoosting.
🎯 Why: To avoid unnecessary allocations and GC overhead in the hot search paths, and to reduce redundant math operations in personalization mapping.
📊 Impact: Reduces heap allocations per search request, and provides a ~30% improvement in applyPersonalizedBoosting.
🔬 Measurement: Verified via unit tests and standard benchmarking suite showing decreased latency.


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

Summary by CodeRabbit

  • Performance

    • Improved search and personalization performance by reducing repeated calculations and temporary data creation.
    • Optimized processing of search results while preserving existing scoring behavior.
  • Documentation

    • Added documentation describing the performance improvements.
  • Benchmarks

    • Updated performance benchmark measurements to reflect the latest results.

@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

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The search engine now uses a precomputed priority lookup and cached values in personalized boosting loops. Benchmark measurements are refreshed, and a changelog entry documents both optimizations.

Changes

Search performance updates

Layer / File(s) Summary
Precomputed priority lookup
language-server/src/core/search-engine.ts, language-server/benchmarks/benchmarks.json
A module-level Uint8Array replaces per-call priority lookup allocation in searchRemainingItems; benchmark measurements are refreshed.
Cached personalized boosting loop
language-server/src/core/search-engine.ts, .jules/bolt.md
applyPersonalizedBoosting caches invariant values and uses indexed iteration while preserving its score blending logic; the optimization is documented.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested labels: codex

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and accurately summarizes the main performance optimizations to remaining-scope iteration and personalization.
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.
✨ 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 perf-optimizations-15282753534866113965

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
language-server/src/core/search-engine.ts (1)

2579-2580: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Remove the unused priorityScopes parameter.

By switching to the module-level PRECOMPUTED_PRIORITY_TYPE_IDS, the priorityScopes parameter is now completely ignored in this method. If the caller passes a different set of scopes in the future, the method will silently use the hardcoded module-level array, which could lead to subtle logic bugs.

Consider removing the priorityScopes parameter from this method's signature and updating the call site.

♻️ Proposed refactor for the signature and caller

Update the method signature (lines 2568-2574):

    private searchRemainingItems(
        maxResults: number,
        processItem: (i: number) => void,
        results: SearchResult[],
        token?: CancellationToken,
    ): void {

And update the call site in searchAllScopesInPriorityOrder (line 2545):

        if (results.length < maxResults && !token?.isCancellationRequested) {
            this.searchRemainingItems(maxResults, processItem, results, token);
        }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@language-server/src/core/search-engine.ts` around lines 2579 - 2580, Remove
the unused priorityScopes parameter from searchRemainingItems and update its
invocation in searchAllScopesInPriorityOrder to pass only maxResults,
processItem, results, and token. Keep the method using
PRECOMPUTED_PRIORITY_TYPE_IDS for priority checks.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@language-server/src/core/search-engine.ts`:
- Around line 2579-2580: Remove the unused priorityScopes parameter from
searchRemainingItems and update its invocation in searchAllScopesInPriorityOrder
to pass only maxResults, processItem, results, and token. Keep the method using
PRECOMPUTED_PRIORITY_TYPE_IDS for priority checks.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 98229df0-1394-45a7-8b26-0e587562dfc7

📥 Commits

Reviewing files that changed from the base of the PR and between 35dd4d7 and 2099af9.

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

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