[rubygems/rubygems] Improve bundler/setup
performance again
On a different patch, it was noticed Ngam Pham that we are calling `LazySpecification#hash` many times, and simply memoizing that led to a very considerable performance improvement in his app. I noticed though that we shouldn't be calling `LazySpecification#hash` that many times, and I located the culprit at `SpecSet#for` where we were deduplicating the partial aggregated result on every iteration. It is enough to do it just once at the end. This leads on a 12% speedup on Rails repository Gemfile vs the previous 8% I was getting from memoizing `LazySpecification#hash`. Also, after this patch memoizing `LazySpecification#hash` has no effect in performance anymore. https://github.com/rubygems/rubygems/commit/68d00a9edd Co-authored-by: Ngan Pham <ngan@users.noreply.github.com>
This commit is contained in:
parent
dccfff943c
commit
c380aac19d
@ -24,7 +24,7 @@ module Bundler
|
||||
|
||||
specs_for_dep = spec_for_dependency(dep, match_current_platform)
|
||||
if specs_for_dep.any?
|
||||
match_current_platform ? specs += specs_for_dep : specs |= specs_for_dep
|
||||
specs += specs_for_dep
|
||||
|
||||
specs_for_dep.first.dependencies.each do |d|
|
||||
next if d.type == :development
|
||||
@ -40,6 +40,8 @@ module Bundler
|
||||
specs << spec
|
||||
end
|
||||
|
||||
specs.uniq! unless match_current_platform
|
||||
|
||||
check ? true : specs
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user