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.
I have a tool for benchmarking Cargoes resolver and a new PubGrub based resolver. Both resolvers spend a lot of time checking whether two
Versions
are equal usingOrd
. For example,.contains
on aBTreeMap<Versions, ...
. @arielb1 pointed out that adding a fast path makes a big difference in the runtime of the resolvers. On master the program reportsPubGrub CPU time: 86.97min, Cargo CPU time: 190.67min
, with this PRPubGrub CPU time: 71.33min, Cargo CPU time: 167.92min
. (For posterity the command iscargo r -r -- -t 100
running commit9dc991f94c45688a6d2d90d29532c5d96fd064b3
) there is about +/- 3 min of run-to-run variability.In most cases
Prerelease
andBuildMetadata
are empty.Prerelease
already did not do much work for theempty == empty
case, most of the time difference therefore comes fromBuildMetadata
.I also considered a simpler
Which is not as big an improvement (
PubGrub CPU time: 75.85min
).Other variations that get approximately the same result, at least within the margin of error are:
or
What are your thoughts about this optimization? Which variation would you prefer? Is there some testing you would like added?