⚡ Bolt: Add O(1) early-exit for path fuzzy matching#549
Conversation
Added `itemPathBitflags` parallel array to the `SearchEngine` class to allow for O(1) early exit when checking `tryFuzzyMatchPath`. By skipping the expensive `Fuzzysort.single()` string operations for paths that do not even contain all the queried characters, fallback search performance is significantly improved. Includes necessary lifecycle array management operations (`ensureCapacity`, `setItems`, `addItems`, `truncateArrays`, `moveItem`, `clear`, and memory calculation). Co-authored-by: AhmmedSamier <17784876+AhmmedSamier@users.noreply.github.com>
|
👋 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 New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
📝 WalkthroughWalkthroughAdds a new ChangesPath Bitflag Early-Exit Optimization
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested labels: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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.
Inline comments:
In @.jules/bolt.md:
- Line 99: The changelog entry date is out of chronological order in the
markdown history list. Update the date in the affected entry so it matches the
surrounding 2026 entries and preserves descending order in the .jules/bolt.md
timeline, using the nearby "2026-08-05" entry and the current heading text as
the reference point.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 048020b0-3d5f-46e5-a31f-d78a671c0893
📒 Files selected for processing (2)
.jules/bolt.mdlanguage-server/src/core/search-engine.ts
| ## 2026-10-27 - [Fast Endpoint Matching Bypass] | ||
| **Learning:** In the `SearchEngine.processItemForSearch` method, `tryUrlEndpointMatch` was previously called for all items that passed the bitflag check or were preserved for URL evaluation, regardless of whether the item was actually an endpoint. This added unnecessary function call overhead and duplicate condition evaluations for non-endpoint items. | ||
| **Action:** Add an explicit O(1) `typeId === 11 /* ENDPOINT */` check alongside `context.isPotentialUrl` directly inside `processItemForSearch` to completely bypass the `tryUrlEndpointMatch` function call for all non-endpoint items. This eliminates redundant evaluations and speeds up the fallback search path. | ||
| ## 2025-05-25 - [O(1) Path Property Early-Exit in Fuzzy Match] |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Entry date appears to be a typo / out of chronological order.
This entry is inserted after the 2026-08-05 entry but is dated 2025-05-25, breaking the file's chronological ordering. Given the other recent entries are dated 2026, this likely should be a 2026 date.
📝 Suggested date correction
-## 2025-05-25 - [O(1) Path Property Early-Exit in Fuzzy Match]
+## 2026-08-06 - [O(1) Path Property Early-Exit in Fuzzy Match]📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| ## 2025-05-25 - [O(1) Path Property Early-Exit in Fuzzy Match] | |
| ## 2026-08-06 - [O(1) Path Property Early-Exit in Fuzzy Match] |
🤖 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 @.jules/bolt.md at line 99, The changelog entry date is out of chronological
order in the markdown history list. Update the date in the affected entry so it
matches the surrounding 2026 entries and preserves descending order in the
.jules/bolt.md timeline, using the nearby "2026-08-05" entry and the current
heading text as the reference point.
💡 What: Added an
itemPathBitflagsparallel array to theSearchEngineclass to perform an O(1) early-exit check intryFuzzyMatchPath.🎯 Why: Because the overall
itemBitflagsaggregate can pass due to a match withinnameorfullName, it does not guarantee that therelativeFilePathcontains the target characters. Without this check, falling back totryFuzzyMatchPathtriggers an expensive string evaluation usingFuzzysort.single()unconditionally, leading to wasted cycles on impossible matches.📊 Impact: Speeds up fallback fuzzy matching in hot loops by entirely skipping expensive string operations for items where the path string doesn't contain all query characters.
🔬 Measurement: Verify by executing
cd language-server && bun run testsuccessfully with the new implementation without regressions, and observing benchmark durations during rapid typing if available.PR created automatically by Jules for task 3706359694628607755 started by @AhmmedSamier
Summary by CodeRabbit
Bug Fixes
Documentation