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

Various speedups on tasks that do not require availability information (e.g. opam list --installed) #5317

Merged
merged 4 commits into from
Aug 20, 2024

Conversation

kit-ty-kate
Copy link
Member

@kit-ty-kate kit-ty-kate commented Oct 15, 2022

Fixes #5314
Queued on #6149

src/state/opamSwitchState.ml Outdated Show resolved Hide resolved
@rjbou rjbou requested a review from AltGr October 24, 2022 14:06
@kit-ty-kate kit-ty-kate added this to the 2.3.0~alpha milestone Jul 15, 2024
@kit-ty-kate kit-ty-kate added the PR: QUEUED Pending pull request, waiting for other work to be merged or closed label Aug 8, 2024
@kit-ty-kate kit-ty-kate removed the PR: QUEUED Pending pull request, waiting for other work to be merged or closed label Aug 8, 2024
@kit-ty-kate kit-ty-kate requested a review from rjbou August 8, 2024 18:12
@rjbou
Copy link
Collaborator

rjbou commented Aug 14, 2024

Bench shows a speed up on opam list --installed on non installed packages 2.1 -> 1.2s \o/

master_changes.md Outdated Show resolved Hide resolved
master_changes.md Outdated Show resolved Hide resolved
master_changes.md Outdated Show resolved Hide resolved
master_changes.md Outdated Show resolved Hide resolved
src/client/opamCommands.ml Outdated Show resolved Hide resolved
@@ -1346,7 +1346,7 @@ let dependencies_filter_to_formula_t ~build ~post st nv =
OpamFilter.filter_formula ~default:true env

let dependencies_t st base_deps_compute deps_compute
~depopts ~installed ?(unavailable=false) packages =
~depopts ~installed ~unavailable packages =
Copy link
Collaborator

Choose a reason for hiding this comment

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

How this change speeds up dependencies computation?

Copy link
Member Author

Choose a reason for hiding this comment

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

it doesn't, but as the dedicated commit says:

Make ?unavailable a non-optional argument to enforce speedups when availability information is not needed

it only enforces that the availability information is used purposefully and ensures that regression won't happen, as the default unavailable=false makes it so that the availability information is used and thus the command will take significantly longer

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yup, I've read the commit message.
The optional argument unavailable will anyway be used on purpose as when calling the function if we want unavailable packages we need to specify it and usually we don't want it. It won't change ow the function is used to have the argument optional or just labelled. As changes show, all omitted unavailable argument were false, as when we need it, it is already to true.
I'm not convinced, but I won't request a change. It's worth mentioning it in the documentation of the function, that requesting only for available package will add an extra computation time.

Copy link
Member Author

Choose a reason for hiding this comment

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

As changes show, all omitted unavailable argument were false, as when we need it, it is already to true.

I don't think that's an viable argument. We could've changed the behaviour of the commands that use this function if we had known and this holds for future change as well. Also i haven't checked that each commands actually require ~unavailable:false. I simply used its previous default to avoid breaking the current behaviour and also because it's outside of the scope of this PR.

It's worth mentioning it in the documentation of the function, that requesting only for available package will add an extra computation time.

I agree. What do you think of e5277ca ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

What do you think of e5277ca ?

lgtm! A squash with 260a06e and it's good to go!

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@kit-ty-kate kit-ty-kate requested review from rjbou and removed request for AltGr August 15, 2024 12:46
@kit-ty-kate kit-ty-kate force-pushed the speedup-opam-list-installed branch 2 times, most recently from e5277ca to df46f93 Compare August 20, 2024 17:17
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.

thanks!

@kit-ty-kate kit-ty-kate merged commit f010979 into ocaml:master Aug 20, 2024
29 checks passed
@kit-ty-kate kit-ty-kate deleted the speedup-opam-list-installed branch August 20, 2024 18:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants