Skip to content

Commit 4f5805f

Browse files
Edouard-chinmatzbot
authored andcommitted
[ruby/rubygems] Run git operations in parallel (take 2):
- In ruby#9100, I opened a patch to run git operations in parallel in order to download git gems more quickly. The parallelization doesn't works when resolving is not needed due to a premature call to `source.specs` hit by this codepath. You can reproduce the problem and see that the gems aren't downloaded in parallel if you have an existing Gemfile and Gemfile.lock. (In my first patch, I forgot to try when a Gemfile.lock already existed). I'd like to introduce a new call to `prelad_git_sources`, when bundler hits the "missing specs" branch. I unforunately couldn't find a single place where we could preload git sources due to the `source.specs` that is called at different path. ruby/rubygems@f25b40f21f
1 parent 3896dbc commit 4f5805f

1 file changed

Lines changed: 13 additions & 8 deletions

File tree

lib/bundler/definition.rb

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ def removed_specs
249249
end
250250

251251
def missing_specs
252+
preload_git_sources
252253
resolve.missing_specs_for(requested_dependencies)
253254
end
254255

@@ -1125,9 +1126,17 @@ def preload_git_source_worker
11251126
end
11261127

11271128
def preload_git_sources
1128-
needed_git_sources.each {|source| preload_git_source_worker.enq(source) }
1129-
ensure
1130-
preload_git_source_worker.stop
1129+
if Gem.ruby_version < Gem::Version.new("3.3")
1130+
# Ruby 3.2 has a bug that incorrectly triggers a circular dependency warning. This version will continue to
1131+
# fetch git repositories one by one.
1132+
return
1133+
end
1134+
1135+
begin
1136+
needed_git_sources.each {|source| preload_git_source_worker.enq(source) }
1137+
ensure
1138+
preload_git_source_worker.stop
1139+
end
11311140
end
11321141

11331142
# Git sources needed for the requested groups (excludes sources only used by --without groups)
@@ -1144,11 +1153,7 @@ def excluded_git_sources
11441153
end
11451154

11461155
def find_source_requirements
1147-
if Gem.ruby_version >= Gem::Version.new("3.3")
1148-
# Ruby 3.2 has a bug that incorrectly triggers a circular dependency warning. This version will continue to
1149-
# fetch git repositories one by one.
1150-
preload_git_sources
1151-
end
1156+
preload_git_sources
11521157

11531158
# Record the specs available in each gem's source, so that those
11541159
# specs will be available later when the resolver knows where to

0 commit comments

Comments
 (0)