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

1.23x faster Frontier using Heap priority queue #126

Merged
merged 1 commit into from
Jan 11, 2022
Merged

Conversation

schneems
Copy link
Collaborator

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.

Before this change 28% of the time was being spent inserting elements into the frontier ![](https://www.dropbox.com/s/f8dom8emthrjtzp/Screen%20Shot%202022-01-06%20at%203.21.46%20PM.png?raw=1)

This change reduces it to 2.7% of time inserting in the queue: ![](https://www.dropbox.com/s/z8j6aytc8ltsbt3/Screen%20Shot%202022-01-06%20at%203.26.31%20PM.png?raw=1)

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.
@schneems schneems force-pushed the schneems/priority-q branch from 00ed241 to 880e460 Compare January 11, 2022 02:51
@schneems schneems merged commit d679a0f into main Jan 11, 2022
@schneems schneems deleted the schneems/priority-q branch January 11, 2022 03:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

1 participant