Skip to content
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

type stability and alloc reduction #8

Merged
merged 6 commits into from
Feb 16, 2025
Merged

Conversation

rafaqz
Copy link
Contributor

@rafaqz rafaqz commented Feb 14, 2025

This PR:

  • fixes type instability due to the possibility of zero length iterators
  • uses sort! instead of sortperm in leafnodes/parentnodes as the vector is not used after the sort anyway
  • reduces memory in a few places, including by reusing scratch in sort!

@asinghvi17
Copy link
Contributor

@maxfreu sorry, I seem to have missed your comment here.
#7 (comment)

We're using this quite heavily in GeometryOps.jl now (see JuliaGeo/GeometryOps.jl#259) so would be happy to either co-maintain or move the repo to JuliaGeo, depending on your preference.

Co-authored-by: Anshul Singhvi <[email protected]>
@rafaqz
Copy link
Contributor Author

rafaqz commented Feb 15, 2025

One more optimisation available is not materialising the extents and indices in leaf nodes, and just keeping the view over extent/index tuple that Iterators.partition gives us. This would make indexing fractionally slower but would remove a lot of allocations.

I tried this and somehow it wasn't faster

@maxfreu
Copy link
Owner

maxfreu commented Feb 16, 2025

Thanks guys! Pretty cool to receive a PR from you :) If you have no further tweaks, I'll merge.

@rafaqz
Copy link
Contributor Author

rafaqz commented Feb 16, 2025

No more changes on my side!

But you can expect more PRs, we will be using this everywhere :)

@maxfreu maxfreu merged commit 62948a4 into maxfreu:main Feb 16, 2025
3 checks passed
@maxfreu
Copy link
Owner

maxfreu commented Feb 16, 2025

love it, thanks! <3

btw: I don't remember why I used sortperm in the first place xD

@rafaqz rafaqz deleted the rs/performance branch February 17, 2025 00:49
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.

3 participants