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

only look at latest specs to suggest name #808

Merged
merged 1 commit into from
Feb 5, 2014

Conversation

tenderlove
Copy link
Contributor

This reduced HTTP requests. Reviewed by @zenspider.

There are too many HTTP requests when someone misspells a gem name and that makes the command very slow. Here is the output before my change:

[aaron@higgins rubygems (master)]$ time ruby -I lib bin/gem install minitist -V
HEAD https://api.rubygems.org/api/v1/dependencies
302 Moved Temporarily
HEAD https://bundler.rubygems.org/api/v1/dependencies
200 OK
GET https://api.rubygems.org/api/v1/dependencies?gems=minitist
302 Moved Temporarily
GET https://bundler.rubygems.org/api/v1/dependencies?gems=minitist
200 OK
ERROR:  Could not find a valid gem 'minitist' (>= 0) in any repository
GET https://api.rubygems.org/prerelease_specs.4.8.gz
302 Moved Temporarily
GET https://s3.amazonaws.com/production.s3.rubygems.org/prerelease_specs.4.8.gz
304 Not Modified
GET https://api.rubygems.org/specs.4.8.gz
302 Moved Temporarily
GET https://s3.amazonaws.com/production.s3.rubygems.org/specs.4.8.gz
304 Not Modified
ERROR:  Possible alternatives: minitest, minigit, minilisp, ministat, linguist

real    0m32.252s
user    0m25.878s
sys 0m0.156s
[aaron@higgins rubygems (master)]$

Here it is after my changes:

[aaron@higgins rubygems (faster_error)]$ time ruby -I lib bin/gem install minitist -V
HEAD https://api.rubygems.org/api/v1/dependencies
302 Moved Temporarily
HEAD https://bundler.rubygems.org/api/v1/dependencies
200 OK
GET https://api.rubygems.org/api/v1/dependencies?gems=minitist
302 Moved Temporarily
GET https://bundler.rubygems.org/api/v1/dependencies?gems=minitist
200 OK
ERROR:  Could not find a valid gem 'minitist' (>= 0) in any repository
GET https://api.rubygems.org/latest_specs.4.8.gz
302 Moved Temporarily
GET https://s3.amazonaws.com/production.s3.rubygems.org/latest_specs.4.8.gz
304 Not Modified
ERROR:  Possible alternatives: minitest, minigit, minilisp, minit, linguist

real    0m10.148s
user    0m3.594s
sys 0m0.094s
[aaron@higgins rubygems (faster_error)]$

Both runs have a heated spec cache, but the new version is ~20 seconds faster.

This reduced HTTP requests. Reviewed by @zenspider
evanphx added a commit that referenced this pull request Feb 5, 2014
only look at latest specs to suggest name
@evanphx evanphx merged commit 284b226 into rubygems:master Feb 5, 2014
@stefanpenner
Copy link

👍

drbrain added a commit that referenced this pull request Feb 5, 2014
@drbrain drbrain added this to the 2.3 milestone Feb 5, 2014
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.

5 participants