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

Improve performance of Pod::Source#search #416

Merged
merged 1 commit into from
Oct 9, 2017

Conversation

dnkoutso
Copy link
Contributor

@dnkoutso dnkoutso commented Oct 9, 2017

screen_shot_2017-10-09_at_10_12_57_am

Within source.rb, just by calling:

    def search(query)
      unless specs_dir
        raise Informative, "Unable to find a source named: `#{name}`"
      end
      if query.is_a?(Dependency)
        query = query.root_name
      end
      found = Pathname.glob(pod_path(query)).map { |path| path.basename.to_s }
      if [query] == found
        set = set(query)
        set if set.specification.name == query # <----------------- this line
      end
    end

It calls Pod::Specification::Set#specification which will call twice the expensive highest_version_spec_path method.

There is no need for us to get the highest version spec if the only thing we need is the name of the specification, which should not be any different given all Podspec names are unique.

This actually saves about 7%-9% in pod install time for a large project that contains a specific pod with 200+ versions (we publish a version nightly). It brought down our pod install from ~53 seconds to ~48 seconds.

set.rb appears immutable so there is no need to evict any of the caching.

@dnkoutso dnkoutso force-pushed the perf_improvements branch 3 times, most recently from 8cb9ead to 8ba84cc Compare October 9, 2017 17:25
@dnkoutso
Copy link
Contributor Author

dnkoutso commented Oct 9, 2017

paired with @justinseanmartin on this.

@@ -71,25 +77,29 @@ def highest_version
versions.first
end

# @return [Version] A version known for this specification.
#
def any_version
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should probably be private?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@dnkoutso dnkoutso changed the title Improve performance of Pod::Specification::Set#specification Improve performance of Pod::Source#search Oct 9, 2017
@dnkoutso
Copy link
Contributor Author

dnkoutso commented Oct 9, 2017

green!

@dnkoutso dnkoutso merged commit 6db1586 into CocoaPods:master Oct 9, 2017
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.

2 participants