Просмотр исходного кода

increase flush threshold to 100 ops

Brian Gough 9 лет назад
Родитель
Сommit
7ce6285e3d

+ 5 - 5
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)

+ 2 - 2
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