diff options
author | danilalexeev <danilalexeev@yandex-team.com> | 2024-11-16 11:10:30 +0300 |
---|---|---|
committer | danilalexeev <danilalexeev@yandex-team.com> | 2024-11-16 11:23:07 +0300 |
commit | 65cc3895230e23087de692519def4ab6677cce48 (patch) | |
tree | 2d4d5b744d701a0d890774830a5fbce00d643685 | |
parent | 334e36694e5c81f3d7df9c889d841005a8149941 (diff) | |
download | ydb-65cc3895230e23087de692519def4ab6677cce48.tar.gz |
YT-23530: Do not compress response message attachments when it is unneeded
commit_hash:4c7c998726dc08c92babb6c9bd6ab8926c095172
-rw-r--r-- | yt/yt/core/rpc/server_detail.cpp | 7 | ||||
-rw-r--r-- | yt/yt/core/rpc/service_detail.h | 16 |
2 files changed, 13 insertions, 10 deletions
diff --git a/yt/yt/core/rpc/server_detail.cpp b/yt/yt/core/rpc/server_detail.cpp index 757a902cb4..8fc2d542eb 100644 --- a/yt/yt/core/rpc/server_detail.cpp +++ b/yt/yt/core/rpc/server_detail.cpp @@ -208,12 +208,7 @@ TSharedRefArray TServiceContextBase::BuildResponseMessage() // COMPAT(danilalexeev): legacy RPC codecs. if (IsResponseBodySerializedWithCompression()) { - if (RequestHeader_->has_response_codec()) { - header.set_codec(ToProto(ResponseCodec_)); - } else { - ResponseBody_ = PushEnvelope(ResponseBody_, ResponseCodec_); - ResponseAttachments_ = DecompressAttachments(ResponseAttachments_, ResponseCodec_); - } + header.set_codec(ToProto(ResponseCodec_)); } auto message = Error_.IsOK() diff --git a/yt/yt/core/rpc/service_detail.h b/yt/yt/core/rpc/service_detail.h index b12bc45ebe..7c43182860 100644 --- a/yt/yt/core/rpc/service_detail.h +++ b/yt/yt/core/rpc/service_detail.h @@ -336,9 +336,17 @@ protected: const auto& underlyingContext = this->GetUnderlyingContext(); const auto& requestHeader = underlyingContext->GetRequestHeader(); - auto codecId = underlyingContext->GetResponseCodec(); - auto serializedBody = SerializeProtoToRefWithCompression(*Response_, codecId); - underlyingContext->SetResponseBodySerializedWithCompression(); + // COMPAT(danilalexeev): legacy RPC codecs. + NCompression::ECodec attachmentCodecId = NCompression::ECodec::None; + auto bodyCodecId = underlyingContext->GetResponseCodec(); + TSharedRef serializedBody; + if (requestHeader.has_response_codec()) { + serializedBody = SerializeProtoToRefWithCompression(*Response_, bodyCodecId); + attachmentCodecId = bodyCodecId; + underlyingContext->SetResponseBodySerializedWithCompression(); + } else { + serializedBody = SerializeProtoToRefWithEnvelope(*Response_, bodyCodecId); + } if (requestHeader.has_response_format()) { auto format = TryCheckedEnumCast<EMessageFormat>(requestHeader.response_format()); @@ -363,7 +371,7 @@ protected: } } - auto responseAttachments = CompressAttachments(Response_->Attachments(), codecId); + auto responseAttachments = CompressAttachments(Response_->Attachments(), attachmentCodecId); return TSerializedResponse{ .Body = std::move(serializedBody), |