summaryrefslogtreecommitdiff
path: root/src/mongo/db/commands/getmore_cmd.cpp
diff options
context:
space:
mode:
authorAdam Midvidy <amidvidy@gmail.com>2015-11-13 17:36:27 -0500
committerAdam Midvidy <amidvidy@gmail.com>2015-11-17 16:42:14 -0500
commit8344af630c5113ab2f9cf2950c384ad926966ff9 (patch)
treeab41398a0c66a4db870ebf8ef105ce172b192754 /src/mongo/db/commands/getmore_cmd.cpp
parentd2adb8eda7fae11b423696e1101e7d0642e19895 (diff)
downloadmongo-8344af630c5113ab2f9cf2950c384ad926966ff9.tar.gz
SERVER-21459 reserve bytes in ReplyBuilder buffer to avoid excessive reallocing
Diffstat (limited to 'src/mongo/db/commands/getmore_cmd.cpp')
-rw-r--r--src/mongo/db/commands/getmore_cmd.cpp7
1 files changed, 7 insertions, 0 deletions
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.
*/