SERVER-105085 Avoid copying batch in received CursorResponse (#36156)

GitOrigin-RevId: 58297c66c6bef8dd65df4b5d04ded076f74e8fb1
This commit is contained in:
Jan 2025-05-15 18:38:30 +02:00 committed by MongoDB Bot
parent cbdca5bdac
commit c92c4464a4
3 changed files with 9 additions and 7 deletions

View File

@ -69,6 +69,9 @@ structs:
description: description:
The response after establishing a cursor on the remote shard, including The response after establishing a cursor on the remote shard, including
the first batch. the first batch.
# Non-const getter is needed here so we can move the batch of BSONObjs out of
# the response if needed.
non_const_getter: true
AsyncResultsMergerParams: AsyncResultsMergerParams:
description: The parameters needed to establish an AsyncResultsMerger. description: The parameters needed to establish an AsyncResultsMerger.

View File

@ -72,7 +72,7 @@ StatusWith<BSONObj> storePossibleCursor(OperationContext* opCtx,
auto result = storePossibleCursor(opCtx, auto result = storePossibleCursor(opCtx,
remoteCursor->getShardId().toString(), remoteCursor->getShardId().toString(),
remoteCursor->getHostAndPort(), remoteCursor->getHostAndPort(),
remoteCursor->getCursorResponse(), std::move(remoteCursor->getCursorResponse()),
requestedNss, requestedNss,
executorPool->getArbitraryExecutor(), executorPool->getArbitraryExecutor(),
Grid::get(opCtx)->getCursorManager(), Grid::get(opCtx)->getCursorManager(),
@ -104,7 +104,7 @@ StatusWith<BSONObj> storePossibleCursor(OperationContext* opCtx,
return incomingCursorResponse.getStatus(); return incomingCursorResponse.getStatus();
} }
const auto& response = incomingCursorResponse.getValue(); auto& response = incomingCursorResponse.getValue();
if (const auto& cursorMetrics = response.getCursorMetrics()) { if (const auto& cursorMetrics = response.getCursorMetrics()) {
CurOp::get(opCtx)->debug().additiveMetrics.aggregateCursorMetrics(*cursorMetrics); CurOp::get(opCtx)->debug().additiveMetrics.aggregateCursorMetrics(*cursorMetrics);
} }
@ -112,7 +112,7 @@ StatusWith<BSONObj> storePossibleCursor(OperationContext* opCtx,
return storePossibleCursor(opCtx, return storePossibleCursor(opCtx,
shardId, shardId,
server, server,
response, std::move(response),
requestedNss, requestedNss,
std::move(executor), std::move(executor),
cursorManager, cursorManager,
@ -124,7 +124,7 @@ StatusWith<BSONObj> storePossibleCursor(OperationContext* opCtx,
StatusWith<BSONObj> storePossibleCursor(OperationContext* opCtx, StatusWith<BSONObj> storePossibleCursor(OperationContext* opCtx,
const ShardId& shardId, const ShardId& shardId,
const HostAndPort& server, const HostAndPort& server,
const CursorResponse& incomingCursorResponse, CursorResponse&& incomingCursorResponse,
const NamespaceString& requestedNss, const NamespaceString& requestedNss,
std::shared_ptr<executor::TaskExecutor> executor, std::shared_ptr<executor::TaskExecutor> executor,
ClusterCursorManager* cursorManager, ClusterCursorManager* cursorManager,
@ -199,7 +199,7 @@ StatusWith<BSONObj> storePossibleCursor(OperationContext* opCtx,
CursorResponse outgoingCursorResponse(requestedNss, CursorResponse outgoingCursorResponse(requestedNss,
clusterCursorId.getValue(), clusterCursorId.getValue(),
incomingCursorResponse.getBatch(), incomingCursorResponse.releaseBatch(),
incomingCursorResponse.getAtClusterTime(), incomingCursorResponse.getAtClusterTime(),
incomingCursorResponse.getPostBatchResumeToken()); incomingCursorResponse.getPostBatchResumeToken());
return outgoingCursorResponse.toBSON(CursorResponse::ResponseType::InitialResponse); return outgoingCursorResponse.toBSON(CursorResponse::ResponseType::InitialResponse);

View File

@ -38,7 +38,6 @@
#include "mongo/db/auth/privilege.h" #include "mongo/db/auth/privilege.h"
#include "mongo/db/namespace_string.h" #include "mongo/db/namespace_string.h"
#include "mongo/db/operation_context.h" #include "mongo/db/operation_context.h"
#include "mongo/db/query/tailable_mode.h"
#include "mongo/db/query/tailable_mode_gen.h" #include "mongo/db/query/tailable_mode_gen.h"
#include "mongo/db/shard_id.h" #include "mongo/db/shard_id.h"
#include "mongo/executor/task_executor.h" #include "mongo/executor/task_executor.h"
@ -106,7 +105,7 @@ StatusWith<BSONObj> storePossibleCursor(OperationContext* opCtx,
StatusWith<BSONObj> storePossibleCursor(OperationContext* opCtx, StatusWith<BSONObj> storePossibleCursor(OperationContext* opCtx,
const ShardId& shardId, const ShardId& shardId,
const HostAndPort& server, const HostAndPort& server,
const CursorResponse& incomingCursorResponse, CursorResponse&& incomingCursorResponse,
const NamespaceString& requestedNss, const NamespaceString& requestedNss,
std::shared_ptr<executor::TaskExecutor> executor, std::shared_ptr<executor::TaskExecutor> executor,
ClusterCursorManager* cursorManager, ClusterCursorManager* cursorManager,