From 1aaeec80208bf73bb57b025ca464a00bda1eeff2 Mon Sep 17 00:00:00 2001 From: Yury Delendik Date: Mon, 24 Feb 2014 10:07:36 -0600 Subject: [PATCH] Heuristic to optimize chunking --- src/core/evaluator.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/core/evaluator.js b/src/core/evaluator.js index 54b4a9e69..226532187 100644 --- a/src/core/evaluator.js +++ b/src/core/evaluator.js @@ -1278,6 +1278,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() { var OperatorList = (function OperatorListClosure() { var CHUNK_SIZE = 1000; + var CHUNK_SIZE_ABOUT = CHUNK_SIZE - 5; // close to chunk size function getTransfers(queue) { var transfers = []; @@ -1326,6 +1327,10 @@ var OperatorList = (function OperatorListClosure() { this.argsArray.push(args); if (this.fnIndex >= CHUNK_SIZE) { this.flush(); + } else if (this.fnIndex >= CHUNK_SIZE_ABOUT && + (fn === OPS.restore || fn === OPS.endText)) { + // heuristic to flush on boundary of restore or endText + this.flush(); } } else { this.fnArray.push(fn);