Patch KDBush to make symbol matching faster #6492
Open
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.
Hopefully solves #6192
As explained in the issue, KDBush currently has no API option to return the "first good match" (or something similar). This means that when finding matches for symbols, we're finding all possible matches, and only then filtering for really only the one that fits, so there's a lot of extra work there we can skip. I tried opening a PR for KDBush to implement a solution (mourner/kdbush#50), but in the meantime, I'm wondering if my approach even works.
I made a small POC with the changes here, using a
rangeSome
function (as opposed to the oldrange
). On my machine it seems to make thefindMatches
function significantly faster:New:

Old:

In both cases I just opened many-overlapping-symbols.html and zoomed out. I tried running the benchmark itself, but it keep crushing for some reason.
Launch Checklist
CHANGELOG.md
under the## main
section.