Skip to content

Commit 8318940

Browse files
committed
Adjust the API_REQUEST_LIMIT:
- ### Problem This limit is used when Bundler fallback to getting a dependency list from a server `/dependencies?gem=` endpoint. Bundler uses this API endpoint fallback when a server doesn't expose the compact index API. This is not used for Rubygems.org, only private servers. This limit is then divided by the number of dependency to get and the result is the number of request we'll be doing. The bottleneck on the client is the network roundtrip. On the server, getting the info of 50 or 100 gems is a bit more expensive but this operation is heavily cached. This is an example of Rubygems.org implementation at the time the dependencies API wasn't deprecated https://github.com/rubygems/rubygems.org/blob/5a3a3ec02acc3a4e3aba077953a393ad20a06842/app/models/gem_dependent.rb#L15 ### Context This limit used to be 100 a while ago but got changed to 50 in e745f8d I don't know why. ### Solution 50 gems to query seems arbitrary low. By doubling this number, we make twice as less API requests which ultimately can shove up to two seconds on application relying on a large number of gems.
1 parent e4fd4ee commit 8318940

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

bundler/lib/bundler/source/rubygems.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class Rubygems < Source
88
autoload :Remote, File.expand_path("rubygems/remote", __dir__)
99

1010
# Ask for X gems per API request
11-
API_REQUEST_SIZE = 50
11+
API_REQUEST_SIZE = 100
1212

1313
attr_accessor :remotes
1414

bundler/spec/bundler/fetcher/dependency_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@
212212
let(:dep_api_uri) { double(:dep_api_uri) }
213213
let(:unmarshalled_gems) { double(:unmarshalled_gems) }
214214
let(:fetch_response) { double(:fetch_response, body: double(:body)) }
215-
let(:rubygems_limit) { 50 }
215+
let(:rubygems_limit) { 100 }
216216

217217
before { allow(subject).to receive(:dependency_api_uri).with(gem_names).and_return(dep_api_uri) }
218218

0 commit comments

Comments
 (0)