Improve goal reorder heuristics. #3208
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.
This change primarily does two things:
For
--reorder-goals
, we use a dedicated datatypeDegree
rather than an
Int
to compute the approximate branchingdegree. We map 0 and 1 to the same value. We then use a
lazy ordering and a shortcutting minimum function to look
for the "best" goal.
The motivation here is that we do not want to spend
unnecessary work. Following any goal that has 0 or 1 as degree
cannot really be "wrong", so we should not look at any others
and waste time.
This will still not always make the use of
--reorder-goals
better than not using it, but it will reduce the overhead
introduced by it.
We use partitioning rather than sorting for most of the other
goal reordering heuristics that are active in all situations.
I think this is slightly more straightforward and also slightly
more efficient, whether
--reorder-goals
is used or not.I have run some preliminary performance comparisons and they
seem to confirm that in both cases separately (with or without
--reorder-goals
), these changes are a relative improvementover the status quo. I will run additional tests before
merging this into master.