-
Notifications
You must be signed in to change notification settings - Fork 711
solver: swap catas with recursion, fuse travs #7519
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
Conversation
|
||
go (PChoiceF qpn rdm gr ts) = PChoice qpn rdm gr <$> sequence (W.mapWithKey (goP qpn) ts) | ||
go (FChoiceF qfn rdm gr b m d ts) = | ||
go (PChoice qpn rdm gr ts) = PChoice qpn rdm gr <$> sequence (W.mapWithKey (goP qpn) (fmap go ts)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sequence . map seems bad idea. Should we add traverseWithKey
to WeightedPSQ
(separately)? Maybe it fuses, but I'm somewhat sceptical about that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. I take it you don't consider that a blocker for this PR, as its about changing a different thing than this PR currently does. Are you ok with approving this pr as is?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can fix it up with traverseWithKey
in the follow up #7533
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added it first, then pushed to this branch.
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
@Mergifyio backport 3.6 |
* solver: swap catas with recursion, fuse travs * whoops * add traverseWithKey to cabal-install-solver (#7533) Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> * replace sequence . mapWithKey with traverseWithKey * more sequence -> traverse * Update Preference.hs fix bad merge * Update Solver.hs Co-authored-by: Gershom Bazerman <[email protected]> Co-authored-by: Emily Pillmore <[email protected]> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> (cherry picked from commit 67c440a) # Conflicts: # cabal-install/cabal-install-solver/src/Distribution/Solver/Modular/Preference.hs # cabal-install/cabal-install-solver/src/Distribution/Solver/Modular/Solver.hs
Command
|
This is the last refactor I had in mind to address the general performance issues discussed in #7466
It attains some modest but real improvement (mainly in allocations) from eliminating the intermediate
cata
calls in favor of explicit recursion in the solver tree.For
trav
calls, rather than eliminate them entirely, it lifts out their intermediate functions to the top level and explicitly fuses them in the solver pipeline, which yields somewhat more significant improvements.Overall not the huge win I hoped, but nonetheless given the straightforward nature of the changes to the code, still worth it I think.