diff options
author | innokentii <innokentii@yandex-team.com> | 2022-10-17 17:59:47 +0300 |
---|---|---|
committer | innokentii <innokentii@yandex-team.com> | 2022-10-17 17:59:47 +0300 |
commit | 1b07a19e808b6b3ba13119b1eef6e241688e01a1 (patch) | |
tree | 3f02cf2e174c50591e88ce0b616a3012ecdde257 | |
parent | 3717bf8db1cedcc16b1fcc364060220d72336734 (diff) | |
download | ydb-1b07a19e808b6b3ba13119b1eef6e241688e01a1.tar.gz |
Remove redundant TString conversion in blobstorage
remove redundant copying
7 files changed, 17 insertions, 10 deletions
diff --git a/library/cpp/actors/util/contiguous_data.h b/library/cpp/actors/util/contiguous_data.h index 8eda607711..303d2df3a2 100644 --- a/library/cpp/actors/util/contiguous_data.h +++ b/library/cpp/actors/util/contiguous_data.h @@ -697,8 +697,15 @@ public: {} explicit TContiguousData(TString s) +#ifndef KIKIMR_TRACE_CONTIGUOUS_DATA_GROW : Backend(std::move(s)) +#endif { +#ifdef KIKIMR_TRACE_CONTIGUOUS_DATA_GROW + auto ss = NActors::TSharedData::Copy(s.data(), s.size()); + TBackTracingOwner::FakeOwner(ss, TBackTracingOwner::INFO_COPIED_STRING); + Backend = TBackend(std::move(ss)); +#endif auto span = Backend.GetData(); Begin = span.data(); End = Begin + span.size(); diff --git a/ydb/core/blobstorage/dsproxy/dsproxy_get_impl.cpp b/ydb/core/blobstorage/dsproxy/dsproxy_get_impl.cpp index b1b486e719..3ff0e74f98 100644 --- a/ydb/core/blobstorage/dsproxy/dsproxy_get_impl.cpp +++ b/ydb/core/blobstorage/dsproxy/dsproxy_get_impl.cpp @@ -362,7 +362,7 @@ void TGetImpl::PrepareVPuts(TLogContext &logCtx, } bytes += put.Buffer.size(); lastItemCount++; - vMultiPut->AddVPut(put.Id, put.Buffer.ConvertToString(), &cookie, put.ExtraBlockChecks, NWilson::TTraceId()); // FIXME: trace + vMultiPut->AddVPut(put.Id, TContiguousData(TRope(put.Buffer)), &cookie, put.ExtraBlockChecks, NWilson::TTraceId()); } vMultiPut->Record.SetCookie(TVMultiPutCookie(diskOrderNumber, lastItemCount, VMultiPutRequests)); ++VMultiPutRequests; diff --git a/ydb/core/blobstorage/dsproxy/dsproxy_put_impl.h b/ydb/core/blobstorage/dsproxy/dsproxy_put_impl.h index 5636a3daf1..cdda2d5715 100644 --- a/ydb/core/blobstorage/dsproxy/dsproxy_put_impl.h +++ b/ydb/core/blobstorage/dsproxy/dsproxy_put_impl.h @@ -496,7 +496,7 @@ protected: } else if constexpr (isVMultiPut) { // this request MUST originate from the TEvPut, so the Span field must be filled in Y_VERIFY(put.Span); - outVPutEvents.back()->AddVPut(put.Id, put.Buffer.ConvertToString(), &cookie, put.ExtraBlockChecks, put.Span->GetTraceId()); + outVPutEvents.back()->AddVPut(put.Id, TContiguousData(TRope(put.Buffer)), &cookie, put.ExtraBlockChecks, put.Span->GetTraceId()); } if (put.IsHandoff) { diff --git a/ydb/core/blobstorage/ut_blobstorage/incorrect_queries.cpp b/ydb/core/blobstorage/ut_blobstorage/incorrect_queries.cpp index 2740f51384..d5c06f4a71 100644 --- a/ydb/core/blobstorage/ut_blobstorage/incorrect_queries.cpp +++ b/ydb/core/blobstorage/ut_blobstorage/incorrect_queries.cpp @@ -80,7 +80,7 @@ Y_UNIT_TEST_SUITE(IncorrectQueries) { TInstant::Max(), NKikimrBlobStorage::EPutHandleClass::TabletLog, false, nullptr)); for(auto [blob, data, status] : blobs) { - static_cast<TEvBlobStorage::TEvVMultiPut*>(ev.get())->AddVPut(blob, data, nullptr, nullptr, NWilson::TTraceId()); + static_cast<TEvBlobStorage::TEvVMultiPut*>(ev.get())->AddVPut(blob, TContiguousData(data), nullptr, nullptr, NWilson::TTraceId()); } static_cast<TEvBlobStorage::TEvVMultiPut*>(ev.get())->Record = proto; @@ -105,7 +105,7 @@ Y_UNIT_TEST_SUITE(IncorrectQueries) { TInstant::Max(), NKikimrBlobStorage::EPutHandleClass::TabletLog, false, nullptr)); for(auto [blob, data, status] : blobs) { - static_cast<TEvBlobStorage::TEvVMultiPut*>(ev.get())->AddVPut(blob, data, nullptr, nullptr, NWilson::TTraceId()); + static_cast<TEvBlobStorage::TEvVMultiPut*>(ev.get())->AddVPut(blob, TContiguousData(data), nullptr, nullptr, NWilson::TTraceId()); } env.WithQueueId(test.Info->GetVDiskInSubgroup(0, blobs[0].BlobId.Hash()), NKikimrBlobStorage::EVDiskQueueId::PutTabletLog, [&](TActorId queueId) { @@ -528,7 +528,7 @@ Y_UNIT_TEST_SUITE(IncorrectQueries) { if (i % 19 != 18) { ++goodCount; TLogoBlobID blob(i, 1, 0, 0, blobSize, 0, 1); - static_cast<TEvBlobStorage::TEvVMultiPut*>(events[i].get())->AddVPut(blob, data, nullptr, nullptr, NWilson::TTraceId()); + static_cast<TEvBlobStorage::TEvVMultiPut*>(events[i].get())->AddVPut(blob, TContiguousData(data), nullptr, nullptr, NWilson::TTraceId()); } } diff --git a/ydb/core/blobstorage/ut_vdisk/lib/helpers.cpp b/ydb/core/blobstorage/ut_vdisk/lib/helpers.cpp index a8bd24cacb..420ef098dd 100644 --- a/ydb/core/blobstorage/ut_vdisk/lib/helpers.cpp +++ b/ydb/core/blobstorage/ut_vdisk/lib/helpers.cpp @@ -448,7 +448,7 @@ class TManyMultiPuts : public TActorBootstrapped<TManyMultiPuts> { TVDiskIdShort mainVDiskId = TIngress::GetMainReplica(&Conf->GroupInfo->GetTopology(), logoBlobID); if (mainVDiskId == VDiskInfo.VDiskID) { ui64 cookieValue = Step; - vMultiPut->AddVPut(logoBlobID, MsgData, &cookieValue, nullptr, NWilson::TTraceId()); + vMultiPut->AddVPut(logoBlobID, TContiguousData(MsgData), &cookieValue, nullptr, NWilson::TTraceId()); putCount++; Step++; diff --git a/ydb/core/blobstorage/vdisk/common/vdisk_events.cpp b/ydb/core/blobstorage/vdisk/common/vdisk_events.cpp index b4a59df5ab..128d4eb116 100644 --- a/ydb/core/blobstorage/vdisk/common/vdisk_events.cpp +++ b/ydb/core/blobstorage/vdisk/common/vdisk_events.cpp @@ -39,12 +39,12 @@ namespace NKikimr { AddPayload(std::move(buffer)); } - void TEvBlobStorage::TEvVMultiPut::StorePayload(NKikimrBlobStorage::TVMultiPutItem &item, const TString& buffer) { + void TEvBlobStorage::TEvVMultiPut::StorePayload(NKikimrBlobStorage::TVMultiPutItem &item, const TContiguousData& buffer) { if (KIKIMR_USE_PROTOBUF_WITH_PAYLOAD) { AddPayload(TRope(buffer)); Y_VERIFY_DEBUG(Record.ItemsSize() == GetPayloadCount()); } else { - item.SetBuffer(buffer); + item.SetBuffer(buffer.GetData(), buffer.GetSize()); } } diff --git a/ydb/core/blobstorage/vdisk/common/vdisk_events.h b/ydb/core/blobstorage/vdisk/common/vdisk_events.h index 6aa58ce3c3..893db104a1 100644 --- a/ydb/core/blobstorage/vdisk/common/vdisk_events.h +++ b/ydb/core/blobstorage/vdisk/common/vdisk_events.h @@ -815,12 +815,12 @@ namespace NKikimr { return sum; } - void StorePayload(NKikimrBlobStorage::TVMultiPutItem &item, const TString &buffer); + void StorePayload(NKikimrBlobStorage::TVMultiPutItem &item, const TContiguousData &buffer); TRope GetItemBuffer(ui64 itemIdx) const; - void AddVPut(const TLogoBlobID &logoBlobId, const TString &buffer, ui64 *cookie, + void AddVPut(const TLogoBlobID &logoBlobId, const TContiguousData &buffer, ui64 *cookie, std::vector<std::pair<ui64, ui32>> *extraBlockChecks, NWilson::TTraceId traceId) { NKikimrBlobStorage::TVMultiPutItem *item = Record.AddItems(); LogoBlobIDFromLogoBlobID(logoBlobId, item->MutableBlobID()); |