From 2f5a822ca4c04847676fe9168e4d26decc6c1970 Mon Sep 17 00:00:00 2001 From: Jakob Borg <jakob@nym.se> Date: Thu, 3 Jul 2014 12:30:10 +0200 Subject: [PATCH] Send initial index in batches --- model/model.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/model/model.go b/model/model.go index 2536b339a..424018196 100644 --- a/model/model.go +++ b/model/model.go @@ -520,7 +520,14 @@ func (m *Model) AddConnection(rawConn io.Closer, protoConn protocol.Connection) if debug { l.Debugf("IDX(out/initial): %s: %q: %d files", nodeID, repo, len(idx)) } - protoConn.Index(repo, idx) + const batchSize = 1000 + for i := 0; i < len(idx); i += batchSize { + if len(idx[i:]) < batchSize { + protoConn.Index(repo, idx[i:]) + } else { + protoConn.Index(repo, idx[i:i+batchSize]) + } + } } }() }