Skip to content
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

Fix performance regression when calling opam install --deps-only on an already installed package #5908

Merged

Conversation

kit-ty-kate
Copy link
Member

@kit-ty-kate kit-ty-kate commented Apr 5, 2024

Fixes #5817
Requires #5909 to be merged first

9aa2290 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 call opam 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 new deps_atoms = [] check is done which fails since it will always be false (unless you're asking opam install --deps pkg-without-any-dependencies-at-all).

The goal of this here PR is to get pkg_skip and pkg_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 in pkg_reinstall is done here to ensure no unnecessary Lazy.force is done since pkg_skip was always empty in the previous version of the code

@kit-ty-kate kit-ty-kate added PR: QUEUED Pending pull request, waiting for other work to be merged or closed and removed PR: WIP Not for merge at this stage labels Apr 5, 2024
@kit-ty-kate kit-ty-kate added this to For beta3 in Opam 2.2.0 Apr 8, 2024
@rjbou rjbou self-requested a review April 8, 2024 12:59
@kit-ty-kate kit-ty-kate added this to the 2.2.0~beta3 milestone Apr 10, 2024
@kit-ty-kate kit-ty-kate force-pushed the fix-regression-opam-install-deps branch from 8c617be to 406ae4d Compare May 3, 2024 09:14
@kit-ty-kate kit-ty-kate added PR: WAITING FOR REVIEW and removed PR: QUEUED Pending pull request, waiting for other work to be merged or closed labels May 3, 2024
@kit-ty-kate kit-ty-kate force-pushed the fix-regression-opam-install-deps branch from 406ae4d to da47f51 Compare May 3, 2024 09:15
@kit-ty-kate kit-ty-kate marked this pull request as ready for review May 3, 2024 09:16
@kit-ty-kate
Copy link
Member Author

ocaml-benchmarks confirms the performance improvement (14s to 2s)

@kit-ty-kate
Copy link
Member Author

code explanation added. Ready for review and merge.

Copy link
Collaborator

@rjbou rjbou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! thanks!

src/client/opamClient.ml Show resolved Hide resolved
@kit-ty-kate kit-ty-kate force-pushed the fix-regression-opam-install-deps branch from da47f51 to d6a982d Compare May 13, 2024 15:08
@kit-ty-kate kit-ty-kate merged commit 685200e into ocaml:master May 13, 2024
29 checks passed
Opam 2.2.0 automation moved this from For beta3 to Done May 13, 2024
@kit-ty-kate kit-ty-kate deleted the fix-regression-opam-install-deps branch May 13, 2024 17:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Opam 2.2.0
  
Done
Development

Successfully merging this pull request may close these issues.

Opam install speed regression in 2.2
2 participants