-
Notifications
You must be signed in to change notification settings - Fork 1
⚡ Bolt: Fast search tracking reset using O(K) clearing #415
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
AhmmedSamier
wants to merge
1
commit into
master
Choose a base branch
from
bolt-fast-search-tracking-17160936138219548008
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| [ | ||
| { | ||
| "name": "Burst Search \"App\" (Matches found)", | ||
| "avgMs": 0.021752440000000206, | ||
| "totalMs": 2.1752440000000206, | ||
| "minMs": 0.0051459999999678985, | ||
| "maxMs": 0.20811000000003332, | ||
| "p95Ms": 0.07331999999996697, | ||
| "stdDevMs": 0.03294990670854845 | ||
| }, | ||
| { | ||
| "name": "Burst Search \"Zzz\" (No match)", | ||
| "avgMs": 17.908657209999998, | ||
| "totalMs": 1790.865721, | ||
| "minMs": 15.286129000000074, | ||
| "maxMs": 22.223959000000036, | ||
| "p95Ms": 20.410278999999946, | ||
| "stdDevMs": 1.5067376363958125 | ||
| }, | ||
| { | ||
| "name": "Burst Search \"S\" (Many matches)", | ||
| "avgMs": 0.5454654399999981, | ||
| "totalMs": 54.54654399999981, | ||
| "minMs": 0.4639810000003308, | ||
| "maxMs": 1.0695709999999963, | ||
| "p95Ms": 0.6355490000000827, | ||
| "stdDevMs": 0.0770148586505619 | ||
| } | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: AhmmedSamier/DeepLens
Length of output: 2838
🏁 Script executed:
Repository: AhmmedSamier/DeepLens
Length of output: 2395
🏁 Script executed:
Repository: AhmmedSamier/DeepLens
Length of output: 2494
🏁 Script executed:
Repository: AhmmedSamier/DeepLens
Length of output: 2195
🏁 Script executed:
Repository: AhmmedSamier/DeepLens
Length of output: 2098
Fix shared-instance visited tracking to prevent concurrent search corruption.
visitedIndicesBuffer/visitedIndicesTracker/visitedTrackerLengthare instance fields used byperformUnifiedSearch. AlthoughperformUnifiedSearchitself is synchronous, it is called fromperformSymbolSearchandperformFileSearch, both of which areasyncand containawaitstatements (at lines 9 and 7 respectively) before theperformUnifiedSearchcall. This means the methods can yield control to the event loop, allowing concurrent callers to reenter and corrupt the shared visited state.Example hazard: Thread A calls
performSymbolSearch, awaits at line 9, and yields. Thread B callsperformSymbolSearch, awaits at line 7, and yields. Thread A resumes and entersperformUnifiedSearchwithvisitedTrackerLengthpotentially non-zero. Thread B resumes and overwrites the visited tracking. Search results silently corrupt.Recommend adding a guard like the one below to catch this at dev-time, or wrap the buffer-using region in a
runWithVisitedTracking(fn)helper to centralize the contract:Guard suggestion
): SearchResult[] { const heap = new MinHeap<SearchResult>(maxResults, (a, b) => a.score - b.score); const searchContext = this.prepareSearchContext(query, scope); + // Guard: visited tracking is instance state and cannot be reentered. + if (this.visitedTrackerLength !== 0) { + this.logger?.error('SearchEngine: visited tracker entered with non-zero length; resetting'); + for (let i = 0; i < this.visitedTrackerLength; i++) { + this.visitedIndicesBuffer[this.visitedIndicesTracker[i]] = 0; + } + this.visitedTrackerLength = 0; + } + try {🤖 Prompt for AI Agents