Skip to content

perf: Reduce some clustering computation#1383

Merged
manthey merged 1 commit intomasterfrom
speed-up-clustering
Jul 10, 2025
Merged

perf: Reduce some clustering computation#1383
manthey merged 1 commit intomasterfrom
speed-up-clustering

Conversation

@manthey
Copy link
Copy Markdown
Contributor

@manthey manthey commented Jul 10, 2025

We were needlessly computing clustering for map levels that are unreachable.

We were needlessly computing clustering for map levels that are
unreachable.
@manthey manthey merged commit 4f618cc into master Jul 10, 2025
12 checks passed
@manthey manthey deleted the speed-up-clustering branch July 10, 2025 12:50
@github-actions
Copy link
Copy Markdown

🎉 This PR is included in version 1.14.7 🎉

The release is available on:

Your semantic-release bot 📦🚀

@manthey
Copy link
Copy Markdown
Contributor Author

manthey commented Jul 10, 2025

As part of this, I had looked at if it was possible to speed up the distance grid code. The bulk of the time clustering is spent in checking if points are near each other. This is done through a distance grid where a bin is computed for a point by making integer values for its coordinate at the granularity of the merge distance. Then, a data structure of grid[row][column][points] is maintained. grid and grid[row] are objects, but the grid[row][column] entries are list, and the points in that bucket are stepped through. I would have thought that an object would be faster, since slicing and push seem like they should be slower than hash lookups. Similarly, a single level object of grid[${row},{column}] is substantially slower even though it has less memory overhead and even though the grid and grid[row] objects cast the integer indices to strings in javascript.

I think any substantial speed up would need to change the point-at-a-time method to some sort of bulk addition.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant