1.23x faster Frontier using Heap priority queue #126
Merged
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.
Before this change 28% of the time was being spent inserting elements into the frontier
This change reduces it to 2.7% of time inserting in the queue:
Previously I didn't optimize this data structure any more as I needed to reject elements from the frontier. This change uses a priority queue (heap data structure) to optimize even further.
Instead of removing items from the frontier directly, I can scan them and mark them for deletion. Then remove any deleted elements at the front of the queue
There's still a lot of time spent in Array#reject! to handle the overlap detection (~35%), but it's quite difficult to optimize.