From 7ce6285e3d39956a27a0c31f2fc1bf7de584ba1e Mon Sep 17 00:00:00 2001 From: Brian Gough Date: Tue, 9 May 2017 10:44:26 +0100 Subject: [PATCH] increase flush threshold to 100 ops --- .../document-updater/app/coffee/HistoryManager.coffee | 10 +++++----- .../coffee/ApplyingUpdatesToADocTests.coffee | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/services/document-updater/app/coffee/HistoryManager.coffee b/services/document-updater/app/coffee/HistoryManager.coffee index c6aa7797cf..17b77a00e6 100644 --- a/services/document-updater/app/coffee/HistoryManager.coffee +++ b/services/document-updater/app/coffee/HistoryManager.coffee @@ -21,17 +21,17 @@ module.exports = HistoryManager = error = new Error("track changes api returned a failure status code: #{res.statusCode}") return callback(error) - FLUSH_EVERY_N_OPS: 50 + FLUSH_EVERY_N_OPS: 100 pushUncompressedHistoryOps: (project_id, doc_id, ops = [], length, callback = (error) ->) -> if ops.length == 0 return callback() HistoryRedisManager.recordDocHasHistoryOps project_id, doc_id, ops, (error) -> return callback(error) if error? return callback() if not length? # don't flush unless we know the length - # We want to flush every 50 ops, i.e. 50, 100, 150, etc - # Find out which 'block' (i.e. 0-49, 50-99) we were in before and after pushing these - # ops. If we've changed, then we've gone over a multiple of 50 and should flush. - # (Most of the time, we will only hit 50 and then flushing will put us back to 0) + # We want to flush every 100 ops, i.e. 100, 200, 300, etc + # Find out which 'block' (i.e. 0-99, 100-199) we were in before and after pushing these + # ops. If we've changed, then we've gone over a multiple of 100 and should flush. + # (Most of the time, we will only hit 100 and then flushing will put us back to 0) previousLength = length - ops.length prevBlock = Math.floor(previousLength / HistoryManager.FLUSH_EVERY_N_OPS) newBlock = Math.floor(length / HistoryManager.FLUSH_EVERY_N_OPS) diff --git a/services/document-updater/test/acceptance/coffee/ApplyingUpdatesToADocTests.coffee b/services/document-updater/test/acceptance/coffee/ApplyingUpdatesToADocTests.coffee index d06119c690..a2eba4c063 100644 --- a/services/document-updater/test/acceptance/coffee/ApplyingUpdatesToADocTests.coffee +++ b/services/document-updater/test/acceptance/coffee/ApplyingUpdatesToADocTests.coffee @@ -207,7 +207,7 @@ describe "Applying updates to a doc", -> before (done) -> [@project_id, @doc_id] = [DocUpdaterClient.randomId(), DocUpdaterClient.randomId()] updates = [] - for v in [0..99] # Should flush after 50 ops + for v in [0..199] # Should flush after 100 ops updates.push doc_id: @doc_id, op: [i: v.toString(), p: 0] @@ -219,7 +219,7 @@ describe "Applying updates to a doc", -> # Send updates in chunks to causes multiple flushes actions = [] - for i in [0..9] + for i in [0..19] do (i) => actions.push (cb) => DocUpdaterClient.sendUpdates @project_id, @doc_id, updates.slice(i*10, (i+1)*10), cb