Skip to content

Commit fa8060e

Browse files
committed
[Backport] refactor TEvPut to store buffer as TRope
1 parent 453906b commit fa8060e

File tree

4 files changed

+23
-15
lines changed

4 files changed

+23
-15
lines changed

contrib/ydb/core/base/blobstorage.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -910,7 +910,7 @@ struct TEvBlobStorage {
910910
std::vector<std::pair<ui64, ui32>> ExtraBlockChecks; // (TabletId, Generation) pairs
911911
std::shared_ptr<TExecutionRelay> ExecutionRelay;
912912

913-
TEvPut(const TLogoBlobID &id, TRcBuf &&buffer, TInstant deadline,
913+
TEvPut(const TLogoBlobID &id, TRope &&buffer, TInstant deadline,
914914
NKikimrBlobStorage::EPutHandleClass handleClass = NKikimrBlobStorage::TabletLog,
915915
ETactic tactic = TacticDefault)
916916
: Id(id)
@@ -933,17 +933,22 @@ struct TEvBlobStorage {
933933
REQUEST_VALGRIND_CHECK_MEM_IS_DEFINED(&tactic, sizeof(tactic));
934934
}
935935

936-
TEvPut(const TLogoBlobID &id, const TString &buffer, TInstant deadline,
936+
TEvPut(const TLogoBlobID &id, TRcBuf &&buffer, TInstant deadline,
937937
NKikimrBlobStorage::EPutHandleClass handleClass = NKikimrBlobStorage::TabletLog,
938938
ETactic tactic = TacticDefault)
939-
: TEvPut(id, TRcBuf(buffer), deadline, handleClass, tactic)
939+
: TEvPut(id, TRope(std::move(buffer)), deadline, handleClass, tactic)
940940
{}
941941

942+
TEvPut(const TLogoBlobID &id, const TString &buffer, TInstant deadline,
943+
NKikimrBlobStorage::EPutHandleClass handleClass = NKikimrBlobStorage::TabletLog,
944+
ETactic tactic = TacticDefault)
945+
: TEvPut(id, TRope(buffer), deadline, handleClass, tactic)
946+
{}
942947

943948
TEvPut(const TLogoBlobID &id, const TSharedData &buffer, TInstant deadline,
944949
NKikimrBlobStorage::EPutHandleClass handleClass = NKikimrBlobStorage::TabletLog,
945950
ETactic tactic = TacticDefault)
946-
: TEvPut(id, TRcBuf(buffer), deadline, handleClass, tactic)
951+
: TEvPut(id, TRope(buffer), deadline, handleClass, tactic)
947952
{}
948953

949954
TString Print(bool isFull) const {

contrib/ydb/core/blob_depot/agent/storage_put.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ namespace NKikimr::NBlobDepot {
115115
footer.StoredBlobId = Request.Id;
116116
}
117117

118-
auto put = [&](EBlobType type, TRcBuf&& buffer) {
118+
auto put = [&](EBlobType type, TRope&& buffer) {
119119
const auto& [id, groupId] = kind.MakeBlobId(Agent, BlobSeqId, type, 0, buffer.size());
120120
Y_ABORT_UNLESS(!locator->HasGroupId() || locator->GetGroupId() == groupId);
121121
locator->SetGroupId(groupId);
@@ -130,17 +130,17 @@ namespace NKikimr::NBlobDepot {
130130

131131
if (SuppressFooter) {
132132
// write the blob as is, we don't need footer for this kind
133-
put(EBlobType::VG_DATA_BLOB, TRcBuf(std::move(Request.Buffer)));
133+
put(EBlobType::VG_DATA_BLOB, std::move(Request.Buffer));
134134
} else if (Request.Buffer.size() + sizeof(TVirtualGroupBlobFooter) <= MaxBlobSize) {
135135
// write single blob with footer
136136
TRope buffer = TRope(std::move(Request.Buffer));
137137
buffer.Insert(buffer.End(), std::move(footerData));
138138
buffer.Compact();
139-
put(EBlobType::VG_COMPOSITE_BLOB, TRcBuf(std::move(buffer)));
139+
put(EBlobType::VG_COMPOSITE_BLOB, std::move(buffer));
140140
} else {
141141
// write data blob and blob with footer
142-
put(EBlobType::VG_DATA_BLOB, TRcBuf(std::move(Request.Buffer)));
143-
put(EBlobType::VG_FOOTER_BLOB, TRcBuf(std::move(footerData)));
142+
put(EBlobType::VG_DATA_BLOB, std::move(Request.Buffer));
143+
put(EBlobType::VG_FOOTER_BLOB, TRope(std::move(footerData)));
144144
}
145145

146146
if (IssueUncertainWrites) {

contrib/ydb/core/blobstorage/dsproxy/dsproxy_put.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ class TBlobStorageGroupPutRequest : public TBlobStorageGroupRequestActor<TBlobSt
472472
ev->Bunch.emplace_back(new IEventHandle(
473473
TActorId() /*recipient*/,
474474
item.Recipient,
475-
put = new TEvBlobStorage::TEvPut(item.BlobId, TRcBuf(item.Buffer), item.Deadline, HandleClass, Tactic),
475+
put = new TEvBlobStorage::TEvPut(item.BlobId, std::move(item.Buffer), item.Deadline, HandleClass, Tactic),
476476
0 /*flags*/,
477477
item.Cookie,
478478
nullptr /*forwardOnNondelivery*/,
@@ -524,9 +524,12 @@ class TBlobStorageGroupPutRequest : public TBlobStorageGroupRequestActor<TBlobSt
524524
if (ev->Orbit.HasShuttles()) {
525525
RootCauseTrack.IsOn = true;
526526
}
527-
ReportBytes(PutImpl.Blobs[0].Buffer.capacity() + sizeof(*this));
528-
529-
RequestBytes = ev->Buffer.size();
527+
RequestBytes = 0;
528+
for (auto &item: PutImpl.Blobs) {
529+
ReportBytes(item.Buffer.capacity());
530+
RequestBytes += item.BufferSize;
531+
}
532+
ReportBytes(sizeof(*this));
530533
RequestHandleClass = HandleClassToHandleClass(HandleClass);
531534
MaxSaneRequests = info->Type.TotalPartCount() * (1ull + info->Type.Handoff()) * 2;
532535
}

contrib/ydb/core/blobstorage/dsproxy/dsproxy_put_impl.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ class TPutImpl {
115115
, Tactic(ev->Tactic)
116116
{
117117
BlobMap.emplace(ev->Id, Blobs.size());
118-
Blobs.emplace_back(ev->Id, TRope(ev->Buffer), recipient, cookie, std::move(traceId), std::move(ev->Orbit),
118+
Blobs.emplace_back(ev->Id, std::move(ev->Buffer), recipient, cookie, std::move(traceId), std::move(ev->Orbit),
119119
std::move(ev->ExtraBlockChecks), true, std::move(ev->ExecutionRelay), ev->Deadline);
120120

121121
auto& blob = Blobs.back();
@@ -144,7 +144,7 @@ class TPutImpl {
144144
Y_ABORT_UNLESS(msg.HandleClass == putHandleClass);
145145
Y_ABORT_UNLESS(msg.Tactic == tactic);
146146
BlobMap.emplace(msg.Id, Blobs.size());
147-
Blobs.emplace_back(msg.Id, TRope(msg.Buffer), ev->Sender, ev->Cookie, std::move(ev->TraceId),
147+
Blobs.emplace_back(msg.Id, std::move(msg.Buffer), ev->Sender, ev->Cookie, std::move(ev->TraceId),
148148
std::move(msg.Orbit), std::move(msg.ExtraBlockChecks), false, std::move(msg.ExecutionRelay),
149149
msg.Deadline);
150150

0 commit comments

Comments
 (0)