Skip to content

Conversation

@rjbou
Copy link
Collaborator

@rjbou rjbou commented Nov 27, 2025

Extracted from #6515, authored by @dra27
I noticed with opam show dune that the switch selections of the switches are read in proportion to the number of versions being displayed. That creates both unnecessary I/O and GC pressure. [...] I'd countenance against hyping the performance improvement on opam show because it won't always show up that way!

dra27 and others added 4 commits November 27, 2025 16:44
'OpamGlobalState.fold_switches' and its derivatives are expensive
functions in terms of I/O. In opam show, in particular, the switch
selections were read for each version.
@rjbou rjbou added this to the 2.6.0~alpha1 milestone Nov 27, 2025
@rjbou rjbou requested a review from kit-ty-kate November 27, 2025 16:15
## List

## Show
* Improve performance of `opam show` by reading switch selection only once instead of once per package-version [#6515 @dra27]
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Suggested change
* Improve performance of `opam show` by reading switch selection only once instead of once per package-version [#6515 @dra27]
* Improve performance of `opam show` by reading switch selection only once instead of once per package-version [#6818 @dra27]


## opam-state
* `OpamRepositoryState.load_opams_from_diff` track added packages to avoid removing version-equivalent packages [#6774 @arozovyk fix #6754]
* `OpamGlobalState.all_installed_versions`: was added [#6515 @dra27]
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Suggested change
* `OpamGlobalState.all_installed_versions`: was added [#6515 @dra27]
* `OpamGlobalState.all_installed_versions`: was added [#6818 @dra27]

## opam-core
* `OpamCmdliner` was added. It is accessible through a new `opam-core.cmdliner` sub-library [#6755 @kit-ty-kate]
* `OpamUrl`: rename and expose `local_path` as `looks_like_local_path` [#5979 @kit-ty-kate]
* `OpamCompat.Map.add_to_list`: was added [#6515 @dra27]
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Suggested change
* `OpamCompat.Map.add_to_list`: was added [#6515 @dra27]
* `OpamCompat.Map.add_to_list`: was added [#6818 @dra27]


(** Returns the map of installed instances of the package name towards the list
of switches they are installed in *)
val installed_versions: 'a global_state -> name -> switch list package_map
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Should we keep installed_versions? It is not used in the codebase, and sherlocode doesn't highlight any use

gt OpamPackage.Set.empty

let installed_versions gt name =
let installed_versions_t gt ~cond =
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The last commit proposes a factorisation of the 2 functions


let installed_versions gt name =
installed_versions_t gt
~cond:(fun nv -> OpamPackage.Name.equal name (OpamPackage.name nv))
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Suggested change
~cond:(fun nv -> OpamPackage.Name.equal name (OpamPackage.name nv))
~cond:(fun nv -> OpamPackage.Name.equal name nv.name)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants