diff options
| author | Josh Nichols <josh.nichols@gusto.com> | 2022-05-13 17:22:54 -0400 |
|---|---|---|
| committer | git <svn-admin@ruby-lang.org> | 2022-06-20 02:34:41 +0900 |
| commit | aeab4058784c86df47a455ffdb08714b337d0209 (patch) | |
| tree | 491beeb9357260424a7cec6e1487d289854dba82 /include | |
| parent | da362fee59b2bff30eb8d63ee15724f5c3aac957 (diff) | |
[rubygems/rubygems] Improve performance of Bundler::SpecSet#for by using hash lookup of handled deps
I was looking at (yet another) flamegraph in speedscope, and used the
'left hand heavy' and was shocked to realize that 0.5s of the 1.7s
is spent in DepProxy#name. This method _only_ delegates the name to an
underlying spec, so it's not complex at all.
It seems to be of how often this line ends up calling it:
next if handled.any?{|d| d.name == dep.name && (match_current_platform || d.__platform == dep.__platform) } || dep.name == "bundler"
The `handled` array is built up as dependencies are handled, so this get
slower as more dependencies are installed.
This change changes how `handled` is track. Instead of just an array, I've
tried using a Hash, with the key being a dep's name, and the value being
a list of deps with that name. This means it's constant time to find
the dependencies with the same name.
I saw a drop from 1.7s to 1.0s against master, and from 0.95s to 0.24s
when used with https://github.com/rubygems/rubygems/pull/5533
https://github.com/rubygems/rubygems/commit/844dac30d4
Diffstat (limited to 'include')
0 files changed, 0 insertions, 0 deletions
