Memoize Bundler::LazySpecification#hash to improve performance#5534
Memoize Bundler::LazySpecification#hash to improve performance#5534technicalpickles wants to merge 1 commit intoruby:masterfrom
Conversation
In local testing, we found `require 'bundler/setup'` took 1.8 seconds to load. I started profiling and looking at flamegraphs for this code, and found a surprising amoutn of time in this method. Memoizing this specific method reduced time by 0.7 to 1.1 seconds, a 38% improvement.
|
Thanks for opening a pull request and helping make RubyGems and Bundler better! Someone from the RubyGems team will take a look at your pull request shortly and leave any feedback. Please make sure that your pull request has tests for any changes or added functionality. We use GitHub Actions to test and make sure your change works functionally and uses acceptable conventions, you can review the current progress of GitHub Actions in the PR status window below. If you have any questions or concerns that you wish to ask, feel free to leave a comment in this PR or join our #rubygems or #bundler channel on Slack. For more information about contributing to the RubyGems project feel free to review our CONTRIBUTING guide |
|
I'm attaching the stackprof data as JSON, which can be viewed with speedscope bundler-test.txt And here's the scaffold I used to run it: require 'benchmark'
require 'stackprof'
result = Benchmark.measure do
StackProf.run(mode: :wall, raw: true, out: 'bundler-test.dump', ignore_gc: true) do
require 'bundler/setup'
end
end
puts result |
|
Yes! And also I think #5533 should make this unnecessary, can you verify? |
|
Confirmed that #5533 would address this case 🚀 |
What was the end-user or developer problem that led to this PR?
In local testing, we found
require 'bundler/setup'took 1.8 seconds to load.I started profiling and looking at flamegraphs for this code, and found
a surprising amount of time in this method.
What is your fix for the problem, implemented in this PR?
Memoizing this specific method reduced time by 0.7 to 1.1 seconds, a 38%
improvement.
Make sure the following tasks are checked
cc @ngan who I paired with on this