SERVER-96561 introduced functionality to insert oplog entries in batches.
There are two small opportunities to improve the performance of the initial implementation:
- we are currently creating temporary InsertStatement objects, which we could avoid.
- instead of copying a vector of InsertStatments into the outer vector of InsertStatements, we could move it.
Suggested change (based on original code introduced in SERVER-96561):
diff --git a/src/mongo/db/s/resharding/resharding_oplog_fetcher.cpp b/src/mongo/db/s/resharding/resharding_oplog_fetcher.cpp index 5a401eb64d9..202cc288600 100644 --- a/src/mongo/db/s/resharding/resharding_oplog_fetcher.cpp +++ b/src/mongo/db/s/resharding/resharding_oplog_fetcher.cpp @@ -148,12 +147,12 @@ std::vector<std::vector<InsertStatement>> getOplogInsertBatches( } else if (totalBytes + currentBytes > maxBytes) { break; } - insertBatch.emplace_back(InsertStatement(currentDoc)); + insertBatch.emplace_back(currentDoc); totalBytes += currentBytes; } while (++currentIndex < aggregateBatch.size() && insertBatch.size() < maxOperations && totalBytes < maxBytes); - insertBatches.push_back(insertBatch); + insertBatches.push_back(std::move(insertBatch)); } return insertBatches;
- is related to
-
SERVER-96561 Make ReshardingOplogFetcher insert oplog entries in batch
- Closed