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

Speed up gem install <gem-that-does-not-exist> #6990

Closed

Conversation

deivid-rodriguez
Copy link
Member

What was the end-user or developer problem that led to this PR?

When target gem does not exist, gem install is very slow.

What is your fix for the problem, implemented in this PR?

My fix is to skip the full index resolve in this case, since we know it will fail already from the compact index result.

Before:

$ time ruby -I lib exe/gem install --debug --verbose pony-gem
NOTE:  Debugging mode prints all exceptions even when rescued
HEAD https://index.rubygems.org/
200 OK
GET https://index.rubygems.org/info/pony-gem
404 Not Found
Exception `Gem::RemoteFetcher::FetchError' at /home/deivid/code/rubygems/rubygems/lib/rubygems/remote_fetcher.rb:237 - bad response Not Found 404 (https://index.rubygems.org/info/pony-gem)
GET https://index.rubygems.org/prerelease_specs.4.8.gz
200 OK
GET https://index.rubygems.org/specs.4.8.gz
200 OK
Exception `Gem::UnsatisfiableDependencyError' at /home/deivid/code/rubygems/rubygems/lib/rubygems/resolver/installer_set.rb:83 - Unable to resolve dependency: user requested 'pony-gem (>= 0)'
ERROR:  Could not find a valid gem 'pony-gem' (>= 0) in any repository
GET https://rubygems.org/latest_specs.4.8.gz
304 Not Modified
ERROR:  Possible alternatives: donsgem, moneygem, poc_gem, pokegem, pry-gem, tinygem

real	0m30,753s
user	0m26,480s
sys	0m0,633s

After

$ time ruby -I lib exe/gem install --debug --verbose pony-gem
NOTE:  Debugging mode prints all exceptions even when rescued
HEAD https://index.rubygems.org/
200 OK
GET https://index.rubygems.org/info/pony-gem
404 Not Found
Exception `Gem::RemoteFetcher::FetchError' at /home/deivid/code/rubygems/rubygems/lib/rubygems/remote_fetcher.rb:237 - bad response Not Found 404 (https://index.rubygems.org/info/pony-gem)
Exception `Gem::UnsatisfiableDependencyError' at /home/deivid/code/rubygems/rubygems/lib/rubygems/resolver/installer_set.rb:83 - Unable to resolve dependency: user requested 'pony-gem (>= 0)'
ERROR:  Could not find a valid gem 'pony-gem' (>= 0) in any repository
GET https://rubygems.org/latest_specs.4.8.gz
304 Not Modified
ERROR:  Possible alternatives: donsgem, moneygem, poc_gem, pokegem, pry-gem, tinygem

real	0m5,709s
user	0m4,909s
sys	0m0,149s

Fixes #6821.

Make sure the following tasks are checked

@deivid-rodriguez
Copy link
Member Author

I'd like to refactor things to not have to match exceptions by message. It doesn't seem trivial though.

@deivid-rodriguez
Copy link
Member Author

As noticed by @simi at #6821 (comment), this may be completing removing the API fallback from gem install which is not what we want. So I set it as a draft.

@segiddins
Copy link
Member

Will this work when installing from servers that don't support the compact index?

@deivid-rodriguez
Copy link
Member Author

I don't think this is the right solution, so let me close this!

I think the best approach would be what we discussed at #6821 (comment) and follow up comments.

@deivid-rodriguez deivid-rodriguez deleted the gem-install-slow-when-name-does-not-exist branch October 19, 2023 16:21
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.

gem install <gem-that-does-not-exist> is very slow
3 participants