Skip to content

Speed up dependency matching#595

Merged
drbrain merged 1 commit into
ruby:masterfrom
sullerandras:speed_up_dependency_matching
Jul 16, 2013
Merged

Speed up dependency matching#595
drbrain merged 1 commit into
ruby:masterfrom
sullerandras:speed_up_dependency_matching

Conversation

@sullerandras

Copy link
Copy Markdown
Contributor

When searching for a specific name, we can just do a binary search to find the gems by their name, instead of iterating thru all the gems (which takes a long time, since there are over 320,000 gem versions).
To do this, we need to sort the tuples by name, which is just a little overhead.

Motivation:
Gem update took 32 seconds on my machine, when there was nothing to update, only to check if there is a newer version.
With the optimized version, it dropped down to 2 seconds.

When searching for a specific name, we can just do a binary search to find the gems by their name, instead of iterating thru all the gems (which takes a long time, since there are over 320,000 gem versions).
To do this, we need to sort the tuples by name, which is just a little overhead.

Motivation:
Gem update took 32 seconds on my machine, when there was nothing to update, only to check if there is a newer version.
With the optimized version, it dropped down to 2 seconds.
@sullerandras

Copy link
Copy Markdown
Contributor Author

Sorry guys, I messed up the original commit, so I created a new pull request.

This is using the #bsearch if it is available, otherwise there is no optimization. Probably most of the developers will upgrade to Ruby 2.0.0 soon. I hope.

The result is incorrect, if the list is not sorted. I tried to avoid this to happen with the freezing. Though since all tests are passing, it may not be not necessary?

@drbrain

drbrain commented Jul 16, 2013

Copy link
Copy Markdown
Member

I don't see the need for freezing, so I will remove those after applying.

drbrain added a commit that referenced this pull request Jul 16, 2013
Speed up dependency matching through #bsearch
@drbrain drbrain merged commit d95bdac into ruby:master Jul 16, 2013
drbrain added a commit that referenced this pull request Jul 16, 2013
Removed freeze

Updated history for #595
drbrain added a commit that referenced this pull request Sep 9, 2013
When available_specs was introduced it didn't sort the :complete type
(which contains sources from two datasets).

Binary search was added to speed up extracting only the needed tuples
from the result of available_specs (see #595).  Binary search depends on
a sorted list.

The assumption that available_specs returns a sorted list was masked by
the tests which sorted the expected value.  The other available_specs
results are all sorted by default, so this was an easy one to miss on
review.

Fixes #636
nobu pushed a commit to nobu/rubygems that referenced this pull request Jan 12, 2014
nobu added a commit to nobu/rubygems that referenced this pull request Feb 7, 2014
nobu pushed a commit to nobu/rubygems that referenced this pull request Feb 7, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants