-
Notifications
You must be signed in to change notification settings - Fork 358
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 25% #5518
Conversation
(* 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 = |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's good to know - getting rid of the remaining allocs should be a lot easier if we don't need to support epochs!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!!
5e1b91b
to
ac8d472
Compare
Crap, my testing method for The speedup for OpamVersionCompare is still present but it's not as significant for real-life commands sadly :( |
ac8d472
to
7bbd13b
Compare
7bbd13b
to
71d09d0
Compare
c9546a9
to
e7587ed
Compare
The latest benchmark shows a 18% speedup, in line with the local tests. I believe this is ready to go. |
f30871b
to
7760468
Compare
After #6144 the PR now improves performance by 28% |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the idea and the code itself, lgtm!
I'm wondering if we should update the header as now we are changing that piece of code. Previous version is still the same code that the one in dose (modulo formatting).
Also, can you update the main comment to highlight the change you made, the origin of the speedup.
7760468
to
510e56c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!!
Doing so does, for example, speeds-up typicalopam 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 madeOpamPackage.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)
Requires #6078