-
Notifications
You must be signed in to change notification settings - Fork 5
Implement an Applicator WithTrait #305
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
Merged
Merged
Conversation
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 significantly decreases allocs. In centroid, 17k allocs are from the actual centroid impl which needs to be looked at. But many allocs are from type uncertainty and trait. We cut down 1000 allocs in centroid. Area was far more affected. ### Before ```julia julia> @be GO.centroid($geoms) Benchmark: 73 samples with 1 evaluation min 1.259 ms (27439 allocs: 864.547 KiB) median 1.298 ms (27439 allocs: 864.547 KiB) mean 1.368 ms (27439 allocs: 864.547 KiB, 0.99% gc time) max 5.351 ms (27439 allocs: 864.547 KiB, 72.51% gc time) ``` ### After ```julia julia> @be GO.centroid($geoms) gc=true Benchmark: 73 samples with 1 evaluation min 1.233 ms (26080 allocs: 815.000 KiB) median 1.301 ms (26080 allocs: 815.000 KiB) mean 1.380 ms (26080 allocs: 815.000 KiB, 1.11% gc time) max 7.332 ms (26080 allocs: 815.000 KiB, 80.89% gc time) ```
This is great. But my main comment is that (also there is no particuar reason it would only be used in |
rafaqz
approved these changes
May 1, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This lets the trait, known by apply anyway, pass into the target function. It's mostly a convenience thing but can cut down on some allocs. Centroid does get 1000 less allocs from this, but the other improvements I made to it outshine it.
Changelog:
WithTrait((trait, obj; kw...) -> ...)
(but it usually won't get any kw, I filter the standard ones out)This is really useful in fix and prepare. They are kind of the same thing but I am going to prototype the new fix pipeline in prepare. It's really needed, ironically, for geom-geom distance queries. Those are n^2 unless you can do some form of branch and bound on spatial trees of the geom or rings.