From e9286de47d2cc7cb7def7ec02610a4461e32a009 Mon Sep 17 00:00:00 2001 From: David Greenspan Date: Mon, 30 Mar 2015 12:40:21 -0700 Subject: [PATCH] Revert part of 5810fd6 to fix perf regression This brings the "rails, gitlabhq" benchmark test back to about 45 seconds on my machine, rather than over 10 minutes. --- packages/logic-solver/logic.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/packages/logic-solver/logic.js b/packages/logic-solver/logic.js index 5a9e6f5cec..061165ac11 100644 --- a/packages/logic-solver/logic.js +++ b/packages/logic-solver/logic.js @@ -1216,12 +1216,14 @@ var binaryWeightedSum = function (varsByWeight) { pushToNth(buckets, lowestWeight+1, carry); } else { // Whether we take variables from the start or end of the - // bucket determines the shape of the tree. Taking them from - // the beginning seems faster (one particular case took 10 - // seconds instead of 22 seconds). - var a = bucket.shift(); - var b = bucket.shift(); - var c = bucket.shift(); + // bucket (i.e. `pop` or `shift`) determines the shape of the tree. + // Empirically, some logic problems are faster with `shift` (2x or so), + // but `pop` gives an order-of-magnitude speed-up on the Meteor Version + // Solver "benchmark-tests" suite (Slava's benchmarks based on data from + // Rails). So, `pop` it is. + var c = bucket.pop(); + var b = bucket.pop(); + var a = bucket.pop(); var sum = new Logic.FullAdderSum(a, b, c); var carry = new Logic.FullAdderCarry(a, b, c); bucket.push(sum);