Normalize the number of workers when performing parallel operations#9400
Merged
Edouard-chin merged 2 commits intoruby:masterfrom Mar 18, 2026
Merged
Normalize the number of workers when performing parallel operations#9400Edouard-chin merged 2 commits intoruby:masterfrom
Edouard-chin merged 2 commits intoruby:masterfrom
Conversation
colby-swandale
approved these changes
Mar 17, 2026
| @app_cache_path ||= self[:cache_path] || "vendor/cache" | ||
| end | ||
|
|
||
| def installation_parallelization |
Member
There was a problem hiding this comment.
Is there any documentation that we need to update to include this information?
Collaborator
Author
There was a problem hiding this comment.
Thanks good call. I updated the man page to reflect that BUNDLE_JOBS affects the number of parallel downloads, lmk what you think.
ca04933 to
0830def
Compare
- ### Problem
I'd like to normalize the number of workers when downloading gems
and use the `BUNDLE_JOBS` configuration (or default to
`Etc.nprocessors`).
Right now the number of workers when doing parallel work seems a bit
random.
### Benchmarks
**Downloading 40 git gems**
=== Comparison Summary ===
Scenario: git-gems (40 gems)
Cold +/- Warm +/-
------------------------------------------------------------------------------
more-downloads 7.94s 1.44s baseline 5.02s 0.31s baseline
master 14.59s 1.67s 83.7% slower 5.72s 0.30s 13.9% slower
_________________________________
**Downloading 249 gems from a fake gemserver with a 300ms latency**
=== Comparison Summary ===
Scenario: no-deps (249 gems)
Cold +/- Warm +/-
------------------------------------------------------------------------------
more-downloads 11.11s 0.66s baseline 1.23s 0.14s baseline
master 16.89s 0.60s 52.0% slower 1.03s 0.09s 16.2% faster
### Context
I originally added those workers count in
1. https://github.com/ruby/rubygems/pull/9087/changes#diff-524173391e40a96577540013a1ad749433454155f79aa05c5d0832235b0bdad1R11
2. https://github.com/ruby/rubygems/pull/9100/changes#diff-04ae823e98259f697c78d2d0b4eab0ced6a83a84a986578703eb2837d6db1a32R1105
For 1. (downloading gems from Rubygems.org)I opted to go with a
hardcoded worker count of 5 and not anything higher as I was
that we could hammer RubyGems.org. I think this concern
is not valid, because requests to download gems don't even hit
RubyGems.org server as there is the fastly CDN in front of the s3
bucket.
For 2. I went with a worker count of 5 to match, without giving this
a second thought.
- Clarify what `BUNDLE_JOB` is used for and that it affects the number of parallel downloads.
0830def to
36f572b
Compare
hsbt
approved these changes
Mar 18, 2026
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.
Note
Benchmarks
Git gems
Gemserver (Fake server with a 300ms latency)
What was the end-user or developer problem that led to this PR?
I'd like to normalize the number of workers when downloading gems and use the
BUNDLE_JOBSconfiguration (or default toEtc.nprocessors). Right now the number of workers when doing parallel work seems a bit random.We can make Bundler download gems even faster.
What is your fix for the problem, implemented in this PR?
Context
I originally added those workers count in:
For 1. (downloading gems from Rubygems.org)I opted to go with a hardcoded worker count of 5 and not anything higher as I was concerned that we could hammer RubyGems.org. I think this concern is not valid, because requests to download gems don't even hit RubyGems.org server as there is the fastly CDN in front of the s3 bucket.
For 2. I went with a worker count of 5 to match, without giving this a second thought.
Solution
Use
BUNDLE_JOBS(or default toEtc.nprocessors) as the number of workers.Make sure the following tasks are checked
cc/ @eileencodes