From 8344af630c5113ab2f9cf2950c384ad926966ff9 Mon Sep 17 00:00:00 2001 From: Adam Midvidy Date: Fri, 13 Nov 2015 17:36:27 -0500 Subject: SERVER-21459 reserve bytes in ReplyBuilder buffer to avoid excessive reallocing --- src/mongo/db/commands/getmore_cmd.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/mongo/db/commands/getmore_cmd.cpp') diff --git a/src/mongo/db/commands/getmore_cmd.cpp b/src/mongo/db/commands/getmore_cmd.cpp index 4ba445d1825..882215570f0 100644 --- a/src/mongo/db/commands/getmore_cmd.cpp +++ b/src/mongo/db/commands/getmore_cmd.cpp @@ -107,6 +107,13 @@ public: return LogicalOp::opGetMore; } + std::size_t reserveBytesForReply() const override { + // The extra 1K is an artifact of how we construct batches. We consider a batch to be full + // when it exceeds the goal batch size. In the case that we are just below the limit and + // then read a large document, the extra 1K helps prevent a final realloc+memcpy. + return FindCommon::kMaxBytesToReturnToClientAtOnce + 1024u; + } + /** * A getMore command increments the getMore counter, not the command counter. */ -- cgit v1.2.1