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

Don't discard candidates matching Ruby metadata #5784

Merged

Conversation

deivid-rodriguez
Copy link
Member

@deivid-rodriguez deivid-rodriguez commented Jul 28, 2022

What was the end-user or developer problem that led to this PR?

Sometimes a Gemfile.lock file will include a variant that matches the current Ruby, but Bundler will discard it because of not being the most platform specific one.

What is your fix for the problem, implemented in this PR?

Bundler materializes lockfiles into real specifications in two steps. First, it filters the dependencies it needs (for example, if BUNDLE_WITHOUT is set or things like that), and chooses a set of specs from those. Then it converts those lockfile specifications into real specifications.

From these two steps, only the second one considered Ruby metadata, while both steps considered platform. This resulted on these candidates already discarded by the time we try to materialize specifications.

This PR merges these two steps into a single pass, so that we consider metadata and platforms at the same time. This also speeds up require "bundler/setup" time in our example big Gemfile by about 2-3%.

✗ hyperfine 'BUNDLER_VERSION=2.4.0.dev ruby -rbundler/setup -e1' 'BUNDLER_VERSION=2.3.19 ruby -rbundler/setup -e1'  
Benchmark 1: BUNDLER_VERSION=2.4.0.dev ruby -rbundler/setup -e1
  Time (mean ± σ):     135.5 ms ±   1.0 ms    [User: 112.1 ms, System: 22.1 ms]
  Range (min … max):   134.2 ms … 138.4 ms    21 runs
 
Benchmark 2: BUNDLER_VERSION=2.3.19 ruby -rbundler/setup -e1
  Time (mean ± σ):     138.9 ms ±   0.5 ms    [User: 115.6 ms, System: 21.9 ms]
  Range (min … max):   138.1 ms … 139.9 ms    21 runs
 
Summary
  'BUNDLER_VERSION=2.4.0.dev ruby -rbundler/setup -e1' ran
    1.03 ± 0.01 times faster than 'BUNDLER_VERSION=2.3.19 ruby -rbundler/setup -e1'

Closes #5715.

Make sure the following tasks are checked

@deivid-rodriguez deivid-rodriguez force-pushed the dont-discard-candidates-matching-ruby-metadata branch 4 times, most recently from efbcbf2 to 4d5d0ab Compare July 29, 2022 20:44
@deivid-rodriguez deivid-rodriguez force-pushed the dont-discard-candidates-matching-ruby-metadata branch from 4d5d0ab to 41026a1 Compare July 30, 2022 19:47
@deivid-rodriguez deivid-rodriguez marked this pull request as ready for review July 31, 2022 08:04
@deivid-rodriguez deivid-rodriguez force-pushed the dont-discard-candidates-matching-ruby-metadata branch 2 times, most recently from 2fc5863 to 583dc07 Compare July 31, 2022 08:08
@deivid-rodriguez
Copy link
Member Author

As a side effect, this PR also implements a different improvement, namely, auto fixing lockfiles generated with different Ruby versions automatically, instead of raising errors. That, of course, unless we are in frozen mode and the lockfile can't be modified. This improvement was already planed since #5435 (comment).

deivid-rodriguez and others added 3 commits July 31, 2022 12:03
Do dependency filtering and materialization in one step. Before,
dependency filtering would not consider ruby metadata so it would
discard variants that end up not being materializable in the end.

Co-authored-by: Ian Ker-Seymer <ian.kerseymer@shopify.com>
@deivid-rodriguez deivid-rodriguez force-pushed the dont-discard-candidates-matching-ruby-metadata branch from af9ce37 to 6e35a6e Compare July 31, 2022 10:03
@deivid-rodriguez deivid-rodriguez changed the title Dont discard candidates matching Ruby metadata Don't discard candidates matching Ruby metadata Jul 31, 2022
@deivid-rodriguez deivid-rodriguez merged commit c63d258 into master Aug 2, 2022
@deivid-rodriguez deivid-rodriguez deleted the dont-discard-candidates-matching-ruby-metadata branch August 2, 2022 07:10
deivid-rodriguez added a commit that referenced this pull request Aug 10, 2022
…ng-ruby-metadata

Don't discard candidates matching Ruby metadata

(cherry picked from commit c63d258)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Do not consider platform gems as candidates when required_ruby_version is incompatible
1 participant