Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[WIP] Cudf request preprocessing #4369

Merged
merged 19 commits into from
Oct 22, 2020
Merged

Conversation

AltGr
Copy link
Member

@AltGr AltGr commented Sep 21, 2020

This adds a resolution of conflicts at low-level (directly on the CUDF
that is sent to the solver, but after the satisfiability check so that
it doesn't have an impact on the error messages).

It might be a better replacement for the high-level preprocessing that
tried to remove conflicting compilers in OpamSwitchState, when
computing the universe. Preliminary tests have shown it can be very
efficient for local switch creation cases where the OCaml version is
constrained.

@AltGr AltGr force-pushed the cudf-preprocessing branch from 45ce811 to d5b68ed Compare September 23, 2020 10:43
@kit-ty-kate
Copy link
Member

kit-ty-kate commented Sep 23, 2020

I've done some tests with this PR and here are my result:

On a fresh ocaml-base-compiler.4.07.1 switch (created by opam 2.1), with builtin-mccs+glpk as solver and OPAMSOLVERTIMEOUT set to 500:

  • opam install --show-actions opam-publish takes:
    • 4 minutes and 32 seconds before this patch (using OPAMPREPRO=0)
    • 4 minutes and 47 seconds with this patch
    • 1 minute and 32 seconds with this patch and OPAMCUDFTRIM=1
  • opam install --show-actions datakit-ci.1.0.0:
    • preprocessing disabled: 1 minute and 09 seconds
    • preprocessing enabled: 15 seconds (!!!)
    • preprocessing + trim enabled: 12 seconds!

Test done on my normal work laptop carying an SSD, Intel i5-5200U and 16Go of RAM.

This is very encouraging results, however not quite enough to get opam-publish working out of the box.

@rjbou rjbou added this to the 2.1.0~beta3 milestone Sep 24, 2020
@rjbou rjbou added the PR: WIP Not for merge at this stage label Oct 9, 2020
@AltGr AltGr force-pushed the cudf-preprocessing branch from 1faf7e4 to 8f66209 Compare October 14, 2020 17:06
@AltGr
Copy link
Member Author

AltGr commented Oct 15, 2020

This ended up gathering quite some stuff; I could split it up, but it is basically just fixes we absolutely want on top of the Cudf preprocessing (with code dependencies); so that would involve either rewriting quite a bit, or waiting anyway for the preprocessing to be merged before filing more PRs.
To summarize:

  • Cudf preprocessing: it's not a silver bullet, but it gives good speedups already (esp. with z3), and I am now reasonably confident about possible regressions.
  • Fix a complex bug that could lead to errors about missing packages or other weird behaviour, due to inaccurate computation of dependencies in the presence of dependency cycles
  • Fix another bug with opam remove -a in the presence of orphan packages
  • Fix a bug with Z3 and the upgrade command
  • Some more trivial changes of build details and error messages

AltGr added 18 commits October 15, 2020 16:09
This appears to give huge solver speedups with MCCS on some tests
It's not what gives the most speedup, and it could be harmful for
maximisation / best-effort requests.
Determines how far we go through the dependencies of the specified packages to
extract conflicts. Defaults to 2, 0 disables conflict detection, more than 5 is
probably meaningless.

Higher values make the preprocessing take around 2s, but that could probably be
optimised.
Computation of dependencies was based on `OpamCudf.Graph.close_and_linearize`,
which is using a topological traversal of the dependency graph. Unfortunately,
when cycles appear (which is now allowed with `post` dependencies, but could
also happen before with malformed opam repos), this can cause dependencies to be
missed.

I believe this could manifest mysteriously in several bugs, but I dug it up on
an issue about `opam remove -a` no longer working, reporting a conflict while
attempting to remove `ocaml-config`.

Note 1: there are small changes in the API for simplicity's sake: the dependency
functions now return sets, and there is a separate sort function. We didn't use
the order anyway and always converted to sets, except in one `opam list` case
where we actually needed only the sort and not the dependency computing.

Note 2: I used a conservative approach (fix the bug first), but it would make
much sense to compute the cone directly from `OpamSolver` without going through
`OpamCudf` and back, which is quite coslty.
- restriction to the cone of mentionned packages was broken
- the command could cause conflicts in the case of orphan packages; when we only
  do removals that won't lead to rebuilds, as is the case with autoremove
  without argument, we can actually just ignore orphans (with argument, only
  keep orphans within the reverse dep cone, as usual).
Instead of removing all unrelated packages, remove just the versions of
related packages that we are guaranteed not to need.
@AltGr AltGr removed the PR: WIP Not for merge at this stage label Oct 16, 2020
Co-authored-by: R. Boujbel <rjbou@ocamlpro.com>
@rjbou rjbou merged commit 821d243 into ocaml:master Oct 22, 2020
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
3 participants