quadtree: sort KNearest results closest first#75
Merged
Conversation
sid6mathur
approved these changes
Oct 13, 2021
sid6mathur
left a comment
There was a problem hiding this comment.
Thank you so much @paulmach . Much gratitude.
benchmarks for move to our own maxHeap benchmark old ns/op new ns/op delta BenchmarkRandomKNearest10-12 4333 2094 -51.67% BenchmarkRandomKNearest100-12 43245 15957 -63.10% benchmark old allocs new allocs delta BenchmarkRandomKNearest10-12 44 14 -68.18% BenchmarkRandomKNearest100-12 369 104 -71.82% benchmark old bytes new bytes delta BenchmarkRandomKNearest10-12 1777 472 -73.44% BenchmarkRandomKNearest100-12 15288 3432 -77.55%
Owner
Author
|
I implement an "internal" maxHeap vs using the std lib one. This makes it twice as fast AND returns sorted results. Allocations are now ~K vs. "nodes seen". If you were doing this 1000s of times for the same quadtree you could implement something to reuse the maxHeap memory. Some sort of |
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
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.
as requested here #67
The results of the
quadtree.KNearestwere just the "heap" order. Now they are sorted closest first.It is slower however, would probably need to implement a custom heap to get rid of the allocs. I did that for the visvalingam simplification here. Hopefully generics will allow this to be simple and performant.