summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Krutisch <jan@krutisch.de>2017-11-02 15:57:12 +0100
committerJan Krutisch <jan@krutisch.de>2017-11-02 20:58:52 +0100
commitc50e30c4cb0c50802a5bfb1afc7a81da8cc478b9 (patch)
tree350cf3077c576b0f4279a6680a807a18f0e52b56
parentd17f2e43236ba53f05b70e7317d218ba94e293c8 (diff)
downloadbundler-c50e30c4cb0c50802a5bfb1afc7a81da8cc478b9.tar.gz
Bail out of reducing depency trees on huge dependency conflict sets
This is a simple fix for #6114, in which sometimes conflict sets get so huge that the current reducing code (which is based on Array#combination) breaks down. By simply bailing out when the conflict set is bigger than a certain size, we'll get a result that is similar to what happened in earlier bundler versions but skip a ton of CPU cycles and memory allocations. I've chosen the limit rather unscientifically by playing around with the result set sizes. 15 seems to be a good compromise but really anything larger than 10 should work (and with work I mean "should not usually not have to be invoked").
-rw-r--r--lib/bundler/resolver.rb2
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/bundler/resolver.rb b/lib/bundler/resolver.rb
index f75c669534..8a3afa3418 100644
--- a/lib/bundler/resolver.rb
+++ b/lib/bundler/resolver.rb
@@ -309,6 +309,8 @@ module Bundler
:solver_name => "Bundler",
:possibility_type => "gem",
:reduce_trees => lambda do |trees|
+ # bail out if tree size is too big for Array#combination to make any sense
+ return trees if trees.size > 15
maximal = 1.upto(trees.size).map do |size|
trees.map(&:last).flatten(1).combination(size).to_a
end.flatten(1).select do |deps|