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

Slightly speed up bundler/setup #4750

Merged
merged 7 commits into from
Jul 12, 2021
Merged

Conversation

deivid-rodriguez
Copy link
Member

@deivid-rodriguez deivid-rodriguez commented Jul 11, 2021

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

We should be making bundler/setup as fast as we can.

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

Refactor some stuff to reduce the work we need to do setup the bundle.

It fixes a small performance regression introduced by #4749 (still unreleased), but the final result should also be ~5-10% faster than the latest release.

On a brand new rails application, I get this:

$ hyperfine --warmup 1 'ruby -rbundler/setup -e1' 'BUNDLER_VERSION=2.2.23 ruby -rbundler/setup -e1' 
Benchmark #1: ruby -rbundler/setup -e1
  Time (mean ± σ):     205.1 ms ±   1.8 ms    [User: 185.7 ms, System: 21.6 ms]
  Range (min … max):   202.7 ms … 209.1 ms    14 runs
 
Benchmark #2: BUNDLER_VERSION=2.2.23 ruby -rbundler/setup -e1
  Time (mean ± σ):     219.4 ms ±   1.5 ms    [User: 196.3 ms, System: 25.4 ms]
  Range (min … max):   217.5 ms … 223.3 ms    13 runs
 
Summary
  'ruby -rbundler/setup -e1' ran
    1.07 ± 0.01 times faster than 'BUNDLER_VERSION=2.2.23 ruby -rbundler/setup -e1'

Make sure the following tasks are checked

Removing it was causing unnecessary re-resolves if you have a
pre-release version of bundler installed.
The method is called at most once per invocation.
Previous version was first materializing the full set of specs, then
re-materializing the "filtered" set of specs needed.

We can do the latter directly.
@deivid-rodriguez deivid-rodriguez marked this pull request as ready for review July 11, 2021 21:43
Copy link
Member

@indirect indirect left a comment

Choose a reason for hiding this comment

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

nice! 7% is a pretty solid win for something that runs so often 🎉

@deivid-rodriguez deivid-rodriguez merged commit 8459ebd into master Jul 12, 2021
@deivid-rodriguez deivid-rodriguez deleted the speed_up_bundler_setup branch July 12, 2021 08:25
deivid-rodriguez added a commit that referenced this pull request Jul 15, 2021
Slightly speed up `bundler/setup`

(cherry picked from commit 8459ebd)
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.

None yet

3 participants