Skip to content

Commit dd4cc31

Browse files
Edouard-chinhsbt
authored andcommitted
Merge pull request #9400 from Shopify/ec-more-downloads
Normalize the number of workers when performing parallel operations (cherry picked from commit be5febe)
1 parent d79e916 commit dd4cc31

7 files changed

Lines changed: 13 additions & 15 deletions

File tree

bundler/lib/bundler/cli/pristine.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def run
5353
true
5454
end.map(&:name)
5555

56-
jobs = installer.send(:installation_parallelization)
56+
jobs = Bundler.settings.installation_parallelization
5757
pristine_count = definition.specs.count - installed_specs.count
5858
# allow a pristining a single gem to skip the parallel worker
5959
jobs = [jobs, pristine_count].min

bundler/lib/bundler/definition.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1122,7 +1122,9 @@ def source_requirements
11221122
end
11231123

11241124
def preload_git_source_worker
1125-
@preload_git_source_worker ||= Bundler::Worker.new(5, "Git source preloading", ->(source, _) { source.specs })
1125+
workers = Bundler.settings.installation_parallelization
1126+
1127+
@preload_git_source_worker ||= Bundler::Worker.new(workers, "Git source preloading", ->(source, _) { source.specs })
11261128
end
11271129

11281130
def preload_git_sources

bundler/lib/bundler/fetcher/gem_remote_fetcher.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class GemRemoteFetcher < Gem::RemoteFetcher
88
def initialize(*)
99
super
1010

11-
@pool_size = 5
11+
@pool_size = Bundler.settings.installation_parallelization
1212
end
1313

1414
def request(*args)

bundler/lib/bundler/installer.rb

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -189,21 +189,13 @@ def install(options)
189189
standalone = options[:standalone]
190190
force = options[:force]
191191
local = options[:local] || options[:"prefer-local"]
192-
jobs = installation_parallelization
192+
jobs = Bundler.settings.installation_parallelization
193193
spec_installations = ParallelInstaller.call(self, @definition.specs, jobs, standalone, force, local: local)
194194
spec_installations.each do |installation|
195195
post_install_messages[installation.name] = installation.post_install_message if installation.has_post_install_message?
196196
end
197197
end
198198

199-
def installation_parallelization
200-
if jobs = Bundler.settings[:jobs]
201-
return jobs
202-
end
203-
204-
Bundler.settings.processor_count
205-
end
206-
207199
def load_plugins
208200
Gem.load_plugins
209201

bundler/lib/bundler/man/bundle-config.1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ When set, no post install messages will be printed\. To silence a single gem, us
146146
Generate a \fBgems\.rb\fR instead of a \fBGemfile\fR when running \fBbundle init\fR\.
147147
.TP
148148
\fBjobs\fR (\fBBUNDLE_JOBS\fR)
149-
The number of gems Bundler can install in parallel\. Defaults to the number of available processors\.
149+
The number of gems Bundler can download and install in parallel\. Defaults to the number of available processors\.
150150
.TP
151151
\fBlockfile\fR (\fBBUNDLE_LOCKFILE\fR)
152152
The path to the lockfile that bundler should use\. By default, Bundler adds \fB\.lock\fR to the end of the \fBgemfile\fR entry\. Can be set to \fBfalse\fR in the Gemfile to disable lockfile creation entirely (see gemfile(5))\.

bundler/lib/bundler/man/bundle-config.1.ronn

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,8 @@ learn more about their operation in [bundle install(1)](bundle-install.1.html).
192192
* `init_gems_rb` (`BUNDLE_INIT_GEMS_RB`):
193193
Generate a `gems.rb` instead of a `Gemfile` when running `bundle init`.
194194
* `jobs` (`BUNDLE_JOBS`):
195-
The number of gems Bundler can install in parallel. Defaults to the number of
196-
available processors.
195+
The number of gems Bundler can download and install in parallel.
196+
Defaults to the number of available processors.
197197
* `lockfile` (`BUNDLE_LOCKFILE`):
198198
The path to the lockfile that bundler should use. By default, Bundler adds
199199
`.lock` to the end of the `gemfile` entry. Can be set to `false` in the

bundler/lib/bundler/settings.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,10 @@ def app_cache_path
303303
@app_cache_path ||= self[:cache_path] || "vendor/cache"
304304
end
305305

306+
def installation_parallelization
307+
self[:jobs] || processor_count
308+
end
309+
306310
def validate!
307311
all.each do |raw_key|
308312
[@local_config, @env_config, @global_config].each do |settings|

0 commit comments

Comments
 (0)