Better algorithm for sorting gem version#9421
Open
Edouard-chin wants to merge 1 commit intoruby:masterfrom
Open
Better algorithm for sorting gem version#9421Edouard-chin wants to merge 1 commit intoruby:masterfrom
Edouard-chin wants to merge 1 commit intoruby:masterfrom
Conversation
- In ruby#9414 I introduced a fast path to compare gem version. The implementation has a couple of caveats such as not computing a sort key for gems having more than 4 segments (major, minor, patch, security), as well as skipping gems that uses a "timestamped" version (such as 0.0.1.20223008103022). The implementation also had to iterate over the segments couple of times. There were some concerns from some users that some gems such as sorbet (currentlt at version 0.6.13055) would at somepoint reach the thresold where we don't compute a sort key (any segment > 65_000). We can instead use a Mixed-radix solution which is more elegant and solve some of those issues (we still don't compute a sort key for timestamped version gems as the integer value may be larger than what we compute for a gem that has a higher version, such as 0.1.0). Co-authored-by: Ufuk Kayserilioglu <ufuk@paralaus.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What was the end-user or developer problem that led to this PR?
In #9414 I introduced a fast path to compare gem version. The implementation has a couple of caveats such as not computing a sort key for gems having more than 4 segments (major, minor, patch, security), as well as skipping gems that uses a "timestamped" version (such as 0.0.1.20223008103022).
The implementation also had to iterate over the segments couple of times. There were some concerns from some users that some gems such as sorbet (currently at version 0.6.13055) would at some point reach the threshold where we don't compute a sort key (any segment
> 65_000).This change was tested on every version returned by Rubygems.org compact index API:
What is your fix for the problem, implemented in this PR?
We can instead use a Mixed-radix solution which is more elegant and solve some of those issues (we still don't compute a sort key for timestamped version gems as the integer value may be larger than what we compute for a gem that has a higher version, such as 0.1.0).
I re-ran the benchmark from #9414, and the results are similar.
Make sure the following tasks are checked
cc/ @paracycle