Fix performance regression when calling opam install --deps-only on an already installed package #5908
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.
Fixes #5817
Requires #5909 to be merged first9aa2290 changed the behaviour of opam in this particular case. This here PR takes a bit of the previous code to get this behaviour back.
Code explanation:
9aa2290 splits the input atoms and the atoms that are the dependencies of each input atoms. The former is empty when
--deps-only
and the second is empty when not in deps-only mode. Now there is a function that takes the former atoms into "atoms that are already installed" and "atoms that are not installed". Near the end of the function before doing the solve, the function tests if the "atoms that are not installed" is empty and simply stops the function in that case. Basically this is all to check if you callopam install installed-pkg
then the solver won't be called unnecessarily. However now if you pass--deps-only
that check won't pass and instead a newdeps_atoms = []
check is done which fails since it will always be false (unless you're askingopam install --deps pkg-without-any-dependencies-at-all
).The goal of this here PR is to get
pkg_skip
andpkg_new
before it's emptied by the deps-only check and only rely on it to check if we should skip the solver. The change inpkg_reinstall
is done here to ensure no unnecessaryLazy.force
is done sincepkg_skip
was always empty in the previous version of the code