Skip to content

⚡ Bolt: O(1) Path Property Early-Exit in Fuzzy Match#582

Closed
AhmmedSamier wants to merge 1 commit into
masterfrom
bolt/optimize-path-fuzzy-match-13506831442698688042
Closed

⚡ Bolt: O(1) Path Property Early-Exit in Fuzzy Match#582
AhmmedSamier wants to merge 1 commit into
masterfrom
bolt/optimize-path-fuzzy-match-13506831442698688042

Conversation

@AhmmedSamier

@AhmmedSamier AhmmedSamier commented Jul 16, 2026

Copy link
Copy Markdown
Owner

💡 What

Added a new itemPathBitflags parallel array to the SearchEngine to track characters present in the relativeFilePath. This enables an O(1) bitwise early-exit check in tryFuzzyMatchPath before performing expensive string evaluations with Fuzzysort.single().

🎯 Why

During fallback fuzzy searching (calculateSearchScore), items are checked against an aggregate itemBitflags array (combining name, fullName, and path). If a query matches characters purely scattered across the name or fullName, the aggregate check passes, and tryFuzzyMatchPath runs unnecessarily. By checking path-specific bitflags first, we skip expensive sorting cycles for irrelevant properties.

📊 Impact

  • Eliminates wasted Fuzzysort.single() evaluations for the path property in fallback search paths.
  • Improves multi-pass search responsiveness during high-volume scans where items have long paths but characters are concentrated in the name.
  • Very minor memory footprint increase (Uint32Array) relative to the significant CPU cycle savings.

🔬 Measurement

  1. Perform a search or burstSearch targeting items using the text scope.
  2. The core fuzzy matching loops will skip Fuzzysort.single() when the queried characters aren't present in the path.
  3. Search tests and language server build confirm exact functionality parity.

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

Summary by CodeRabbit

  • Performance Improvements
    • Improved path search responsiveness by quickly skipping fuzzy matching when the search query cannot match an item’s file path.
    • Applied the optimization consistently as search indexes are added, updated, compacted, cleared, and cached.

Added `itemPathBitflags` parallel array in `SearchEngine` to perform an O(1) bitflag early-exit check in `tryFuzzyMatchPath`. This skips expensive `Fuzzysort.single()` evaluations when the required characters don't exist in the file path, solving false positives on aggregate `itemBitflags` matches.

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 16, 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: e896872b-6c44-46bf-82ab-55bc14cabbad

📥 Commits

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

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

📝 Walkthrough

Walkthrough

Adds per-item path bitflags throughout the search index lifecycle and uses them in tryFuzzyMatchPath to skip fuzzy matching when query characters are absent from a file path.

Changes

Path bitflag search optimization

Layer / File(s) Summary
Path bitflag index lifecycle
language-server/src/core/search-engine.ts
Adds itemPathBitflags, computes path flags from relativeFilePath, includes them in aggregate flags, and maintains the array across indexing, resizing, compaction, clearing, and cache sizing.
Path match context and early exit
language-server/src/core/search-engine.ts, .jules/bolt.md
Passes path bitflags into the search context and checks them in tryFuzzyMatchPath before invoking fuzzy matching; documents the optimization.

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

Possibly related PRs

🚥 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 accurately 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/optimize-path-fuzzy-match-13506831442698688042

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