Skip to content

⚡ Bolt: Add O(1) early exit for path fuzzy matching#563

Closed
AhmmedSamier wants to merge 1 commit into
masterfrom
bolt-fast-path-fuzzy-match-11397874699091500188
Closed

⚡ Bolt: Add O(1) early exit for path fuzzy matching#563
AhmmedSamier wants to merge 1 commit into
masterfrom
bolt-fast-path-fuzzy-match-11397874699091500188

Conversation

@AhmmedSamier

@AhmmedSamier AhmmedSamier commented Jul 11, 2026

Copy link
Copy Markdown
Owner

💡 What:
Added an itemPathBitflags parallel array to the SearchEngine class, storing a bitmask for the relativeFilePath of each item. This specific bitmask is then used to perform an O(1) early-exit check inside the tryFuzzyMatchPath function.

🎯 Why:
In the fallback path matching algorithm, if an item's aggregate bitflag (representing characters in name, full name, OR path) passed the query check, it would eventually fall through to tryFuzzyMatchPath. This would execute an expensive Fuzzysort.single() operation, even if the characters were actually located entirely within the name or fullName and were missing from the path itself. By isolating the path characters into their own itemPathBitflags bitmask, we can instantly reject path evaluations that will mathematically fail fuzzy matching, saving CPU cycles and allocations.

📊 Impact:
Significantly reduces the number of expensive Fuzzysort.single executions for items that enter the path fallback scoring tier. This speeds up the overall search performance by eliminating wasted string matching iterations, particularly when searching large codebases where many items pass the aggregate bitmask due to characters spread across different properties.

🔬 Measurement:
Verified by running bun run test in both language-server and vscode-extension directories. The existing extensive test suite ensures no fuzzy matching regressions are introduced by the new early-exit optimization.


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

Summary by CodeRabbit

  • Performance
    • Improved fuzzy path matching responsiveness by quickly filtering out non-matching file paths before performing more expensive comparisons.
    • Maintained search performance as files are added, removed, moved, or cleared.

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.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@coderabbitai

coderabbitai Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c8c51656-90cf-4fa4-9dbf-dd1632c1a636

📥 Commits

Reviewing files that changed from the base of the PR and between 124aa21 and 913c02f.

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

📝 Walkthrough

Walkthrough

SearchEngine now maintains path-specific bitflags for indexed items and uses them to skip impossible relativeFilePath fuzzy matches before invoking expensive scoring.

Changes

Path Bitmask Optimization

Layer / File(s) Summary
Path bitmask storage and preparation
language-server/src/core/search-engine.ts
Adds itemPathBitflags, maintains it across initialization, insertion, removal, compaction, and clearing, and populates it from relativeFilePath bitflags.
Path-match context and early exit
language-server/src/core/search-engine.ts, .jules/bolt.md
Passes path bitflags into search context, includes them in cache sizing, and rejects impossible path matches before fuzzy scoring; documents the optimization.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant SearchEngine
  participant SearchContext
  participant tryFuzzyMatchPath
  participant Fuzzysort
  SearchEngine->>SearchContext: expose itemPathBitflags
  SearchContext->>tryFuzzyMatchPath: provide path bitflags for candidate
  tryFuzzyMatchPath->>tryFuzzyMatchPath: check required path characters
  tryFuzzyMatchPath->>Fuzzysort: score relativeFilePath when eligible
  Fuzzysort-->>tryFuzzyMatchPath: return fuzzy score
Loading

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 clearly summarizes the main change: an O(1) early-exit optimization for path fuzzy matching.
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 bolt-fast-path-fuzzy-match-11397874699091500188

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.

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