In order to get deterministic order, we don't actually have to sort the entire queue after every pass, we just have to enqueue in a deterministic order.
This change adds a separate frontier that gets sorted before it gets appended to the queue after each pass.
For what it's worth, this doesn't affect performance in a perceivable way for us, so feel free to reject it, but on the same workload as my last PR, this goes from making 242651 comparisons to only 5106 comparisons, which seems fairly close to optimal.
In order to get deterministic order, we don't actually have to sort the entire queue after every pass, we just have to enqueue in a deterministic order.
This change adds a separate frontier that gets sorted before it gets appended to the queue after each pass.
For what it's worth, this doesn't affect performance in a perceivable way for us, so feel free to reject it, but on the same workload as my last PR, this goes from making 242651 comparisons to only 5106 comparisons, which seems fairly close to optimal.