Skip to content

⚡ Bolt: [O(1) early-exit for fullName and path fuzzy matching]#526

Closed
AhmmedSamier wants to merge 1 commit into
masterfrom
bolt-fast-fallback-early-exit-17088394927139376535
Closed

⚡ Bolt: [O(1) early-exit for fullName and path fuzzy matching]#526
AhmmedSamier wants to merge 1 commit into
masterfrom
bolt-fast-fallback-early-exit-17088394927139376535

Conversation

@AhmmedSamier

@AhmmedSamier AhmmedSamier commented Jun 23, 2026

Copy link
Copy Markdown
Owner

💡 What: Added parallel bitflag arrays (itemFullNameBitflags and itemPathBitflags) to the SearchEngine struct-of-arrays architecture to perform fast O(1) character filtering before executing expensive Fuzzysort.single() evaluations on the fullName and path properties.
🎯 Why: An item may pass the aggregate itemBitflags check (because the characters exist somewhere within the name, fullName, or path), but then subsequently fail the tryFuzzyMatchFullName or tryFuzzyMatchPath fallback evaluations. Adding property-specific bitflags avoids calling into Fuzzysort entirely when the specific string is guaranteed not to contain the required query characters.
📊 Impact: Reduces expensive fuzzy evaluations for fallback properties during deep search queries, skipping unviable paths immediately.
🔬 Measurement: Verified using language-server benchmarks and test suites, preventing significant fuzzy match overhead in worst-case text searches.


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

Summary by CodeRabbit

  • Performance Improvements
    • Enhanced search performance with optimized query execution for faster, more responsive results.

Added `itemFullNameBitflags` and `itemPathBitflags` parallel arrays to `SearchEngine` to perform an O(1) early-exit before expensive fuzzy sorting in `tryFuzzyMatchFullName` and `tryFuzzyMatchPath`. This skips non-matching evaluations for items that pass the aggregate bitmask but fail the specific property's character requirements.

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 Jun 23, 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: 0cc63dda-b141-4f93-b386-bc87520b25ff

📥 Commits

Reviewing files that changed from the base of the PR and between fbf483d and 0d7f501.

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

📝 Walkthrough

Walkthrough

SearchEngine gains two new Uint32Array fields (itemFullNameBitflags, itemPathBitflags) tracking per-item character bitflags for fullName and relativeFilePath. computeItemBitflags is refactored to return four values; all lifecycle operations are extended; and tryFuzzyMatchFullName/tryFuzzyMatchPath add O(1) bitflag intersection gates that return -Infinity before invoking Fuzzysort. Benchmark results, plan.md, and .jules/bolt.md are updated accordingly.

Changes

Bolt: per-property bitflag O(1) early-exit for fuzzy matching

Layer / File(s) Summary
Bitflag array fields and lifecycle management
language-server/src/core/search-engine.ts
Declares itemFullNameBitflags and itemPathBitflags as private Uint32Array fields and extends setItems, addItems (capacity resize), truncateArrays, moveItem, clear, and getCacheSize to maintain and account for the new arrays.
computeItemBitflags refactor and prepareItemAtIndex wiring
language-server/src/core/search-engine.ts
computeItemBitflags now returns nameFlags, fullNameFlags, pathFlags, and aggregateFlags; prepareItemAtIndex stores the per-property values into the new parallel arrays.
Search context threading and fuzzy matcher gates
language-server/src/core/search-engine.ts
prepareSearchContext passes the two new arrays into the hot-loop context; tryFuzzyMatchFullName and tryFuzzyMatchPath each open with a bitflag intersection check that short-circuits to -Infinity before any Fuzzysort call.
Benchmark results, plan, and design notes
language-server/benchmarks/benchmarks.json, plan.md, .jules/bolt.md
Updated benchmark timing snapshots for all existing entries; plan.md rewritten to the bitflag implementation spec with revised PR title; bolt.md records a dated design note on the per-property bitflag lifecycle.

Sequence Diagram(s)

sequenceDiagram
  participant SearchLoop
  participant tryFuzzyMatchFullName
  participant tryFuzzyMatchPath
  participant Fuzzysort

  SearchLoop->>tryFuzzyMatchFullName: item index + queryBitflags
  tryFuzzyMatchFullName->>tryFuzzyMatchFullName: itemFullNameBitflags[i] & queryBitflags check
  alt gate fails
    tryFuzzyMatchFullName-->>SearchLoop: -Infinity
  else gate passes
    tryFuzzyMatchFullName->>Fuzzysort: fuzzy match on fullName
    Fuzzysort-->>SearchLoop: score
  end

  SearchLoop->>tryFuzzyMatchPath: item index + queryBitflags
  tryFuzzyMatchPath->>tryFuzzyMatchPath: itemPathBitflags[i] & queryBitflags check
  alt gate fails
    tryFuzzyMatchPath-->>SearchLoop: -Infinity
  else gate passes
    tryFuzzyMatchPath->>Fuzzysort: fuzzy match on path
    Fuzzysort-->>SearchLoop: score
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • AhmmedSamier/DeepLens#256: Adds a bitflag-based O(1) early rejection gate in calculateSearchScore, directly overlapping with this PR's same pattern applied in tryFuzzyMatchFullName/tryFuzzyMatchPath.
  • AhmmedSamier/DeepLens#503: Adds per-property bitflag early-exit in tryFuzzyMatchName, the sibling matcher to the two fuzzy methods this PR gates.
  • AhmmedSamier/DeepLens#428: Fixes missing truncation of SearchEngine parallel arrays and adds a regression test for array-length synchronization — directly relevant to this PR's new truncateArrays and moveItem extensions.

Suggested labels

codex

🐇 Two new arrays, flags for each name and path,
A bitwise AND checks before the fuzzy wrath.
-Infinity returned when chars don't align,
No Fuzzysort called — O(1) by design! ⚡
Hop hop, the search is fast, the benchmarks shine! 🎯

🚥 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 primary optimization: adding O(1) early-exit for fullName and path fuzzy matching via the Bolt performance initiative.
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-fast-fallback-early-exit-17088394927139376535

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.

@AhmmedSamier

Copy link
Copy Markdown
Owner Author

Closing as duplicate of #533 which implements the same bitflag early-exit optimization.

@google-labs-jules

Copy link
Copy Markdown
Contributor

Closing as duplicate of #533 which implements the same bitflag early-exit optimization.

Understood. Acknowledging that this work is a duplicate and stopping work on this task.

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