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

Speedup OpamVersionCompare by 15% #5518

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

kit-ty-kate
Copy link
Member

@kit-ty-kate kit-ty-kate commented Apr 21, 2023

Doing so does, for example, speeds-up typical opam show <pkg> by 50%

I also tried a completely new implementation of OpamPackage.Version.compare that would have sped-up the comparison function by 30% instead but doing so made OpamPackage.Version.of_string slower, as i was actually parsing the string first and pre-processed it so the comparison function is faster, but it wasn't worth it in the end.

F.i.x.e.s. #5479 as it speeds-up switch loading time from 0.22s to 0.044s on my M1Pro.
Related to #4245 (cc @emillon)

(* splits a version into (epoch,rest), without the separating ':'. The
* epoch is delimited by the leftmost occurrence of ':' in x, and is ""
* in case there is no ':' in x. *)
let extract_epoch x =
Copy link
Member Author

Choose a reason for hiding this comment

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

Note for reviewers: This was removed because OpamPackage.Version.of_string never allowed :. This is only an unused remnant of the Dose3 implementation.

@kit-ty-kate kit-ty-kate added this to PR in progress in Opam 2.2.0 via automation Apr 24, 2023
@rjbou rjbou added this to the 2.2.0~alpha milestone Apr 24, 2023
@rjbou rjbou moved this from PR in progress to PR to review for 2.2.0~alpha in Opam 2.2.0 Apr 24, 2023
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!!

@rjbou rjbou moved this from PR to review for 2.2.0~alpha to PR finalised (merge with CI) in Opam 2.2.0 Apr 24, 2023
@kit-ty-kate kit-ty-kate added PR: QUEUED Pending pull request, waiting for other work to be merged or closed and removed STATE: READY TO MERGE labels Apr 25, 2023
Doing so does, for example, speeds-up typical `opam show <pkg>` by 50%
@kit-ty-kate kit-ty-kate added STATE: READY TO MERGE and removed PR: QUEUED Pending pull request, waiting for other work to be merged or closed STATE: READY TO MERGE labels Apr 26, 2023
@kit-ty-kate
Copy link
Member Author

Crap, my testing method for opam show and the misspelled command wasn't good.
What I was actually testing was the performance difference between OCaml 4.14.1 and 5.0.0 (how is that giving us 50% performance for free!?!)
Thanks to #5525 we're actually able to detect performance changes reliably so at least that's the good news.

The speedup for OpamVersionCompare is still present but it's not as significant for real-life commands sadly :(

@rjbou rjbou moved this from PR finalised (merge with CI) to PR in progress in Opam 2.2.0 Apr 27, 2023
@rjbou rjbou removed this from PR in progress in Opam 2.2.0 Apr 27, 2023
@rjbou rjbou removed this from the 2.2.0~alpha milestone Apr 27, 2023
@rjbou rjbou added PR: WIP Not for merge at this stage PR: NEEDS UPDATE labels May 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants