Skip to content

Conversation

HatulaPro
Copy link

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 old range). On my machine it seems to make the findMatches function significantly faster:

New:
image

Old:
image

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

  • Confirm your changes do not include backports from Mapbox projects (unless with compliant license) - if you are not sure about this, please ask!
  • Briefly describe the changes in this PR.
  • Link to related issues.
  • Include before/after visuals or gifs if this PR includes visual changes.
  • Write tests for all new functionality.
  • Document any changes to public APIs.
  • Post benchmark scores.
  • Add an entry to CHANGELOG.md under the ## main section.

@HatulaPro
Copy link
Author

Small note: my KDBush PR is not as tailor-made to maplibre's needs, so not sure if we'd get the same performance benefits. Still better than better than none probably

@bradymadden97
Copy link
Contributor

bradymadden97 commented Oct 6, 2025

Note: worth comparing against #6192 (comment)

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.

2 participants