[前][次][番号順一覧][スレッド一覧]

ruby-changes:71835

From: David <ko1@a...>
Date: Mon, 16 May 2022 17:24:24 +0900 (JST)
Subject: [ruby-changes:71835] c380aac19d (master): [rubygems/rubygems] Improve `bundler/setup` performance again

https://git.ruby-lang.org/ruby.git/commit/?id=c380aac19d

From c380aac19d097f1d38d2299fe3f64567b42fb55d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?David=20Rodr=C3=ADguez?= <deivid.rodriguez@r...>
Date: Fri, 13 May 2022 11:26:20 +0200
Subject: [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@u...>
---
 lib/bundler/spec_set.rb | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lib/bundler/spec_set.rb b/lib/bundler/spec_set.rb
index a19d18388a..dc55e5eaed 100644
--- a/lib/bundler/spec_set.rb
+++ b/lib/bundler/spec_set.rb
@@ -24,7 +24,7 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/spec_set.rb#L24
 
         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 https://github.com/ruby/ruby/blob/trunk/lib/bundler/spec_set.rb#L40
         specs << spec
       end
 
+      specs.uniq! unless match_current_platform
+
       check ? true : specs
     end
 
-- 
cgit v1.2.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]