From b8a327d16e258b2d459ec0c25fe08cc456b066b6 Mon Sep 17 00:00:00 2001 From: ivanmorozov Date: Sat, 14 Oct 2023 21:06:05 +0300 Subject: [PATCH] KIKIMR-19215: additional signals --- .../columnshard/blobs_action/abstract/read.h | 1 + .../blobs_action/abstract/remove.cpp | 1 + .../blobs_action/abstract/remove.h | 6 +++ .../blobs_action/abstract/storage.h | 15 +++--- .../tx/columnshard/blobs_action/bs/gc.cpp | 9 +++- ydb/core/tx/columnshard/blobs_action/bs/gc.h | 6 +++ .../tx/columnshard/blobs_action/bs/read.h | 2 +- .../columnshard/blobs_action/bs/storage.cpp | 3 +- .../tx/columnshard/blobs_action/bs/storage.h | 2 +- .../counters/CMakeLists.darwin-x86_64.txt | 2 + .../counters/CMakeLists.linux-aarch64.txt | 2 + .../counters/CMakeLists.linux-x86_64.txt | 2 + .../counters/CMakeLists.windows-x86_64.txt | 2 + .../blobs_action/counters/remove_declare.cpp | 23 +++++++++ .../blobs_action/counters/remove_declare.h | 47 +++++++++++++++++++ .../blobs_action/counters/remove_gc.cpp | 19 ++++++++ .../blobs_action/counters/remove_gc.h | 39 +++++++++++++++ .../blobs_action/counters/storage.cpp | 2 + .../blobs_action/counters/storage.h | 4 ++ .../columnshard/blobs_action/counters/ya.make | 2 + .../tx/columnshard/blobs_action/tier/gc.cpp | 6 +++ .../tx/columnshard/blobs_action/tier/gc.h | 11 ++++- .../columnshard/blobs_action/tier/storage.cpp | 4 +- .../columnshard/blobs_action/tier/storage.h | 2 +- 24 files changed, 198 insertions(+), 14 deletions(-) create mode 100644 ydb/core/tx/columnshard/blobs_action/counters/remove_declare.cpp create mode 100644 ydb/core/tx/columnshard/blobs_action/counters/remove_declare.h create mode 100644 ydb/core/tx/columnshard/blobs_action/counters/remove_gc.cpp create mode 100644 ydb/core/tx/columnshard/blobs_action/counters/remove_gc.h diff --git a/ydb/core/tx/columnshard/blobs_action/abstract/read.h b/ydb/core/tx/columnshard/blobs_action/abstract/read.h index cbfa52b32dd1..70f5129a32e7 100644 --- a/ydb/core/tx/columnshard/blobs_action/abstract/read.h +++ b/ydb/core/tx/columnshard/blobs_action/abstract/read.h @@ -21,6 +21,7 @@ class IBlobsReadingAction: public ICommonBlobsAction { THashMap Fails; std::shared_ptr Counters; bool Started = false; + YDB_ACCESSOR(bool, IsBackgroundProcess, true); protected: virtual void DoStartReading(const THashMap>& range) = 0; void StartReading(THashMap>&& ranges); diff --git a/ydb/core/tx/columnshard/blobs_action/abstract/remove.cpp b/ydb/core/tx/columnshard/blobs_action/abstract/remove.cpp index 47c75900b34c..72d058b14d82 100644 --- a/ydb/core/tx/columnshard/blobs_action/abstract/remove.cpp +++ b/ydb/core/tx/columnshard/blobs_action/abstract/remove.cpp @@ -6,6 +6,7 @@ namespace NKikimr::NOlap { void IBlobsDeclareRemovingAction::DeclareRemove(const TUnifiedBlobId& blobId) { if (DeclaredBlobs.emplace(blobId).second) { ACFL_DEBUG("event", "DeclareRemove")("blob_id", blobId); + Counters->OnRequest(blobId.BlobSize()); return DoDeclareRemove(blobId); } } diff --git a/ydb/core/tx/columnshard/blobs_action/abstract/remove.h b/ydb/core/tx/columnshard/blobs_action/abstract/remove.h index 85b092f5de3b..6c4daffd12e2 100644 --- a/ydb/core/tx/columnshard/blobs_action/abstract/remove.h +++ b/ydb/core/tx/columnshard/blobs_action/abstract/remove.h @@ -3,6 +3,7 @@ #include #include #include +#include namespace NKikimr::NColumnShard { class TColumnShard; @@ -14,6 +15,7 @@ namespace NKikimr::NOlap { class IBlobsDeclareRemovingAction: public ICommonBlobsAction { private: using TBase = ICommonBlobsAction; + std::shared_ptr Counters; YDB_READONLY_DEF(THashSet, DeclaredBlobs); protected: virtual void DoDeclareRemove(const TUnifiedBlobId& blobId) = 0; @@ -26,6 +28,10 @@ class IBlobsDeclareRemovingAction: public ICommonBlobsAction { } + void SetCounters(const std::shared_ptr& counters) { + Counters = counters; + } + void DeclareRemove(const TUnifiedBlobId& blobId); void OnExecuteTxAfterRemoving(NColumnShard::TColumnShard& self, NColumnShard::TBlobManagerDb& dbBlobs, const bool success) { return DoOnExecuteTxAfterRemoving(self, dbBlobs, success); diff --git a/ydb/core/tx/columnshard/blobs_action/abstract/storage.h b/ydb/core/tx/columnshard/blobs_action/abstract/storage.h index 8e9df493bf67..b0a565ee55bf 100644 --- a/ydb/core/tx/columnshard/blobs_action/abstract/storage.h +++ b/ydb/core/tx/columnshard/blobs_action/abstract/storage.h @@ -6,6 +6,7 @@ #include #include +#include #include namespace NKikimr::NColumnShard { @@ -47,9 +48,9 @@ class IBlobsStorageOperator { return ""; } - virtual std::shared_ptr DoStartGCAction() const = 0; - std::shared_ptr StartGCAction() const { - return DoStartGCAction(); + virtual std::shared_ptr DoStartGCAction(const std::shared_ptr& counters) const = 0; + std::shared_ptr StartGCAction(const std::shared_ptr& counters) const { + return DoStartGCAction(counters); } public: @@ -76,8 +77,10 @@ class IBlobsStorageOperator { return DoOnTieringModified(tiers); } - std::shared_ptr StartDeclareRemovingAction(const TString& /*consumerId*/) { - return DoStartDeclareRemovingAction(); + std::shared_ptr StartDeclareRemovingAction(const TString& consumerId) { + auto result = DoStartDeclareRemovingAction(); + result->SetCounters(Counters->GetConsumerCounter(consumerId)->GetRemoveDeclareCounters()); + return result; } std::shared_ptr StartWritingAction(const TString& consumerId) { auto result = DoStartWritingAction(); @@ -96,7 +99,7 @@ class IBlobsStorageOperator { if (Stopped) { return false; } - auto task = StartGCAction(); + auto task = StartGCAction(Counters->GetConsumerCounter("GC")->GetRemoveGCCounters()); if (!task) { return false; } diff --git a/ydb/core/tx/columnshard/blobs_action/bs/gc.cpp b/ydb/core/tx/columnshard/blobs_action/bs/gc.cpp index acdd15c7b897..f140922fa2a6 100644 --- a/ydb/core/tx/columnshard/blobs_action/bs/gc.cpp +++ b/ydb/core/tx/columnshard/blobs_action/bs/gc.cpp @@ -57,6 +57,11 @@ void TGCTask::OnGCResult(TEvBlobStorage::TEvCollectGarbageResult::TPtr ev) { Y_ABORT_UNLESS(itGroup != ListsByGroupId.end()); const auto& keepList = itGroup->second.KeepList; const auto& dontKeepList = itGroup->second.DontKeepList; + + for (auto&& i : dontKeepList) { + Counters->OnReply(i.BlobSize()); + } + AFL_DEBUG(NKikimrServices::TX_COLUMNSHARD)("actor", "OnGCResult")("keep_list", keepList.size())("dont_keep_list", dontKeepList.size()); for (const auto& blobId : keepList) { @@ -83,7 +88,9 @@ THashMap> TGCT new TVector(gl.second.KeepList.begin(), gl.second.KeepList.end()), new TVector(gl.second.DontKeepList.begin(), gl.second.DontKeepList.end()), TInstant::Max(), true); - + for (auto&& i : gl.second.DontKeepList) { + Counters->OnRequest(i.BlobSize()); + } Y_ABORT_UNLESS(CounterToGroupInFlight.emplace(perGenerationCounter, group).second); perGenerationCounter += requests[group]->PerGenerationCounterStepSize(); } diff --git a/ydb/core/tx/columnshard/blobs_action/bs/gc.h b/ydb/core/tx/columnshard/blobs_action/bs/gc.h index 013f1a1029ad..c8ee866acb63 100644 --- a/ydb/core/tx/columnshard/blobs_action/bs/gc.h +++ b/ydb/core/tx/columnshard/blobs_action/bs/gc.h @@ -2,6 +2,7 @@ #include #include +#include #include namespace NKikimr::NOlap::NBlobOperations::NBlobStorage { @@ -23,6 +24,7 @@ class TGCTask: public IBlobsGCAction { std::deque KeepsToErase; std::deque DeletesToErase; std::shared_ptr Manager; + std::shared_ptr Counters; protected: virtual void DoOnExecuteTxAfterCleaning(NColumnShard::TColumnShard& self, NColumnShard::TBlobManagerDb& dbBlobs) override; virtual bool DoOnCompleteTxAfterCleaning(NColumnShard::TColumnShard& self, const std::shared_ptr& taskAction) override; @@ -31,6 +33,10 @@ class TGCTask: public IBlobsGCAction { return ListsByGroupId.empty(); } + void SetCounters(const std::shared_ptr& counters) { + Counters = counters; + } + TGCTask(const TString& storageId, TGCListsByGroup&& listsByGroupId, const NColumnShard::TGenStep& collectGenStepInFlight, std::deque&& keepsToErase, std::deque&& deletesToErase, const std::shared_ptr& manager); diff --git a/ydb/core/tx/columnshard/blobs_action/bs/read.h b/ydb/core/tx/columnshard/blobs_action/bs/read.h index a30c38eebe9e..e21c66866a05 100644 --- a/ydb/core/tx/columnshard/blobs_action/bs/read.h +++ b/ydb/core/tx/columnshard/blobs_action/bs/read.h @@ -13,7 +13,7 @@ class TReadingAction: public IBlobsReadingAction { protected: virtual void DoStartReading(const THashMap>& ranges) override { for (auto&& i : ranges) { - NBlobCache::TReadBlobRangeOptions readOpts{.CacheAfterRead = true, .IsBackgroud = true, .WithDeadline = false}; + NBlobCache::TReadBlobRangeOptions readOpts{.CacheAfterRead = true, .IsBackgroud = GetIsBackgroundProcess(), .WithDeadline = false}; std::vector rangesLocal(i.second.begin(), i.second.end()); TActorContext::AsActorContext().Send(BlobCacheActorId, new NBlobCache::TEvBlobCache::TEvReadBlobRangeBatch(std::move(rangesLocal), std::move(readOpts))); AFL_DEBUG(NKikimrServices::TX_COLUMNSHARD)("blob_id", i.first)("count", i.second.size()); diff --git a/ydb/core/tx/columnshard/blobs_action/bs/storage.cpp b/ydb/core/tx/columnshard/blobs_action/bs/storage.cpp index 5293284fb78e..7b9b864b8bb7 100644 --- a/ydb/core/tx/columnshard/blobs_action/bs/storage.cpp +++ b/ydb/core/tx/columnshard/blobs_action/bs/storage.cpp @@ -20,12 +20,13 @@ std::shared_ptr TOperator::DoStartReadingAc return std::make_shared(GetStorageId(), BlobCacheActorId); } -std::shared_ptr TOperator::DoStartGCAction() const { +std::shared_ptr TOperator::DoStartGCAction(const std::shared_ptr& counters) const { auto gcTask = Manager->BuildGCTask(GetStorageId(), Manager); if (!gcTask || gcTask->IsEmpty()) { AFL_DEBUG(NKikimrServices::TX_COLUMNSHARD)("event", "StartGCSkipped"); return nullptr; } + gcTask->SetCounters(counters); auto requests = gcTask->BuildRequests(PerGenerationCounter, Manager->GetTabletId(), Manager->GetCurrentGen()); AFL_VERIFY(requests.size()); AFL_DEBUG(NKikimrServices::TX_COLUMNSHARD)("event", "StartGC")("requests_count", requests.size()); diff --git a/ydb/core/tx/columnshard/blobs_action/bs/storage.h b/ydb/core/tx/columnshard/blobs_action/bs/storage.h index 49e97a61d9a0..9e39e6173f0e 100644 --- a/ydb/core/tx/columnshard/blobs_action/bs/storage.h +++ b/ydb/core/tx/columnshard/blobs_action/bs/storage.h @@ -18,7 +18,7 @@ class TOperator: public IBlobsStorageOperator { virtual std::shared_ptr DoStartDeclareRemovingAction() override; virtual std::shared_ptr DoStartWritingAction() override; virtual std::shared_ptr DoStartReadingAction() override; - virtual std::shared_ptr DoStartGCAction() const override; + virtual std::shared_ptr DoStartGCAction(const std::shared_ptr& counters) const override; virtual bool DoLoad(NColumnShard::IBlobManagerDb& dbBlobs) override { return Manager->LoadState(dbBlobs); } diff --git a/ydb/core/tx/columnshard/blobs_action/counters/CMakeLists.darwin-x86_64.txt b/ydb/core/tx/columnshard/blobs_action/counters/CMakeLists.darwin-x86_64.txt index 3f2c60a24c62..44ff16687a6c 100644 --- a/ydb/core/tx/columnshard/blobs_action/counters/CMakeLists.darwin-x86_64.txt +++ b/ydb/core/tx/columnshard/blobs_action/counters/CMakeLists.darwin-x86_64.txt @@ -19,4 +19,6 @@ target_sources(columnshard-blobs_action-counters PRIVATE ${CMAKE_SOURCE_DIR}/ydb/core/tx/columnshard/blobs_action/counters/read.cpp ${CMAKE_SOURCE_DIR}/ydb/core/tx/columnshard/blobs_action/counters/storage.cpp ${CMAKE_SOURCE_DIR}/ydb/core/tx/columnshard/blobs_action/counters/write.cpp + ${CMAKE_SOURCE_DIR}/ydb/core/tx/columnshard/blobs_action/counters/remove_declare.cpp + ${CMAKE_SOURCE_DIR}/ydb/core/tx/columnshard/blobs_action/counters/remove_gc.cpp ) diff --git a/ydb/core/tx/columnshard/blobs_action/counters/CMakeLists.linux-aarch64.txt b/ydb/core/tx/columnshard/blobs_action/counters/CMakeLists.linux-aarch64.txt index 536e94a6219d..8f18b7f3166f 100644 --- a/ydb/core/tx/columnshard/blobs_action/counters/CMakeLists.linux-aarch64.txt +++ b/ydb/core/tx/columnshard/blobs_action/counters/CMakeLists.linux-aarch64.txt @@ -20,4 +20,6 @@ target_sources(columnshard-blobs_action-counters PRIVATE ${CMAKE_SOURCE_DIR}/ydb/core/tx/columnshard/blobs_action/counters/read.cpp ${CMAKE_SOURCE_DIR}/ydb/core/tx/columnshard/blobs_action/counters/storage.cpp ${CMAKE_SOURCE_DIR}/ydb/core/tx/columnshard/blobs_action/counters/write.cpp + ${CMAKE_SOURCE_DIR}/ydb/core/tx/columnshard/blobs_action/counters/remove_declare.cpp + ${CMAKE_SOURCE_DIR}/ydb/core/tx/columnshard/blobs_action/counters/remove_gc.cpp ) diff --git a/ydb/core/tx/columnshard/blobs_action/counters/CMakeLists.linux-x86_64.txt b/ydb/core/tx/columnshard/blobs_action/counters/CMakeLists.linux-x86_64.txt index 536e94a6219d..8f18b7f3166f 100644 --- a/ydb/core/tx/columnshard/blobs_action/counters/CMakeLists.linux-x86_64.txt +++ b/ydb/core/tx/columnshard/blobs_action/counters/CMakeLists.linux-x86_64.txt @@ -20,4 +20,6 @@ target_sources(columnshard-blobs_action-counters PRIVATE ${CMAKE_SOURCE_DIR}/ydb/core/tx/columnshard/blobs_action/counters/read.cpp ${CMAKE_SOURCE_DIR}/ydb/core/tx/columnshard/blobs_action/counters/storage.cpp ${CMAKE_SOURCE_DIR}/ydb/core/tx/columnshard/blobs_action/counters/write.cpp + ${CMAKE_SOURCE_DIR}/ydb/core/tx/columnshard/blobs_action/counters/remove_declare.cpp + ${CMAKE_SOURCE_DIR}/ydb/core/tx/columnshard/blobs_action/counters/remove_gc.cpp ) diff --git a/ydb/core/tx/columnshard/blobs_action/counters/CMakeLists.windows-x86_64.txt b/ydb/core/tx/columnshard/blobs_action/counters/CMakeLists.windows-x86_64.txt index 3f2c60a24c62..44ff16687a6c 100644 --- a/ydb/core/tx/columnshard/blobs_action/counters/CMakeLists.windows-x86_64.txt +++ b/ydb/core/tx/columnshard/blobs_action/counters/CMakeLists.windows-x86_64.txt @@ -19,4 +19,6 @@ target_sources(columnshard-blobs_action-counters PRIVATE ${CMAKE_SOURCE_DIR}/ydb/core/tx/columnshard/blobs_action/counters/read.cpp ${CMAKE_SOURCE_DIR}/ydb/core/tx/columnshard/blobs_action/counters/storage.cpp ${CMAKE_SOURCE_DIR}/ydb/core/tx/columnshard/blobs_action/counters/write.cpp + ${CMAKE_SOURCE_DIR}/ydb/core/tx/columnshard/blobs_action/counters/remove_declare.cpp + ${CMAKE_SOURCE_DIR}/ydb/core/tx/columnshard/blobs_action/counters/remove_gc.cpp ) diff --git a/ydb/core/tx/columnshard/blobs_action/counters/remove_declare.cpp b/ydb/core/tx/columnshard/blobs_action/counters/remove_declare.cpp new file mode 100644 index 000000000000..b3fb6ba1ef24 --- /dev/null +++ b/ydb/core/tx/columnshard/blobs_action/counters/remove_declare.cpp @@ -0,0 +1,23 @@ +#include "remove_declare.h" +#include "storage.h" + +namespace NKikimr::NOlap::NBlobOperations { + +TRemoveDeclareCounters::TRemoveDeclareCounters(const TConsumerCounters& owner) + : TBase(owner, "RemoveDeclare") +{ + RequestsCount = TBase::GetDeriviative("Requests/Count"); + RequestBytes = TBase::GetDeriviative("Requests/Bytes"); + + RepliesCount = TBase::GetDeriviative("Replies/Count"); + ReplyBytes = TBase::GetDeriviative("Replies/Bytes"); + ReplyDurationBySize = TBase::GetHistogram("Replies/Duration/Bytes", NMonitoring::ExponentialHistogram(15, 2, 1)); + ReplyDurationByCount = TBase::GetHistogram("Replies/Duration/Count", NMonitoring::ExponentialHistogram(15, 2, 1)); + + FailsCount = TBase::GetDeriviative("Fails/Count"); + FailBytes = TBase::GetDeriviative("Fails/Bytes"); + FailDurationBySize = TBase::GetHistogram("Fails/Duration/Bytes", NMonitoring::ExponentialHistogram(15, 2, 2)); + FailDurationByCount = TBase::GetHistogram("Fails/Duration/Count", NMonitoring::ExponentialHistogram(15, 2, 2)); +} + +} diff --git a/ydb/core/tx/columnshard/blobs_action/counters/remove_declare.h b/ydb/core/tx/columnshard/blobs_action/counters/remove_declare.h new file mode 100644 index 000000000000..4e11a6c68f40 --- /dev/null +++ b/ydb/core/tx/columnshard/blobs_action/counters/remove_declare.h @@ -0,0 +1,47 @@ +#pragma once +#include +#include + +namespace NKikimr::NOlap::NBlobOperations { + +class TConsumerCounters; + +class TRemoveDeclareCounters: public NColumnShard::TCommonCountersOwner { +private: + using TBase = NColumnShard::TCommonCountersOwner; + NMonitoring::TDynamicCounters::TCounterPtr RequestsCount; + NMonitoring::TDynamicCounters::TCounterPtr RequestBytes; + + NMonitoring::TDynamicCounters::TCounterPtr RepliesCount; + NMonitoring::TDynamicCounters::TCounterPtr ReplyBytes; + NMonitoring::THistogramPtr ReplyDurationByCount; + NMonitoring::THistogramPtr ReplyDurationBySize; + + NMonitoring::TDynamicCounters::TCounterPtr FailsCount; + NMonitoring::TDynamicCounters::TCounterPtr FailBytes; + NMonitoring::THistogramPtr FailDurationByCount; + NMonitoring::THistogramPtr FailDurationBySize; +public: + TRemoveDeclareCounters(const TConsumerCounters& owner); + + void OnRequest(const ui64 bytes) const { + RequestsCount->Add(1); + RequestBytes->Add(bytes); + } + + void OnReply(const ui64 bytes, const TDuration d) const { + RepliesCount->Add(1); + ReplyBytes->Add(bytes); + ReplyDurationByCount->Collect((i64)d.MilliSeconds()); + ReplyDurationBySize->Collect((i64)d.MilliSeconds(), (i64)bytes); + } + + void OnFail(const ui64 bytes, const TDuration d) const { + FailsCount->Add(1); + FailBytes->Add(bytes); + FailDurationByCount->Collect((i64)d.MilliSeconds()); + FailDurationBySize->Collect((i64)d.MilliSeconds(), (i64)bytes); + } +}; + +} diff --git a/ydb/core/tx/columnshard/blobs_action/counters/remove_gc.cpp b/ydb/core/tx/columnshard/blobs_action/counters/remove_gc.cpp new file mode 100644 index 000000000000..599b73689ac3 --- /dev/null +++ b/ydb/core/tx/columnshard/blobs_action/counters/remove_gc.cpp @@ -0,0 +1,19 @@ +#include "remove_gc.h" +#include "storage.h" + +namespace NKikimr::NOlap::NBlobOperations { + +TRemoveGCCounters::TRemoveGCCounters(const TConsumerCounters& owner) + : TBase(owner, "RemoveGC") +{ + RequestsCount = TBase::GetDeriviative("Requests/Count"); + RequestBytes = TBase::GetDeriviative("Requests/Bytes"); + + RepliesCount = TBase::GetDeriviative("Replies/Count"); + ReplyBytes = TBase::GetDeriviative("Replies/Bytes"); + + FailsCount = TBase::GetDeriviative("Fails/Count"); + FailBytes = TBase::GetDeriviative("Fails/Bytes"); +} + +} diff --git a/ydb/core/tx/columnshard/blobs_action/counters/remove_gc.h b/ydb/core/tx/columnshard/blobs_action/counters/remove_gc.h new file mode 100644 index 000000000000..d2f7c268c221 --- /dev/null +++ b/ydb/core/tx/columnshard/blobs_action/counters/remove_gc.h @@ -0,0 +1,39 @@ +#pragma once +#include +#include + +namespace NKikimr::NOlap::NBlobOperations { + +class TConsumerCounters; + +class TRemoveGCCounters: public NColumnShard::TCommonCountersOwner { +private: + using TBase = NColumnShard::TCommonCountersOwner; + NMonitoring::TDynamicCounters::TCounterPtr RequestsCount; + NMonitoring::TDynamicCounters::TCounterPtr RequestBytes; + + NMonitoring::TDynamicCounters::TCounterPtr RepliesCount; + NMonitoring::TDynamicCounters::TCounterPtr ReplyBytes; + + NMonitoring::TDynamicCounters::TCounterPtr FailsCount; + NMonitoring::TDynamicCounters::TCounterPtr FailBytes; +public: + TRemoveGCCounters(const TConsumerCounters& owner); + + void OnRequest(const ui64 bytes) const { + RequestsCount->Add(1); + RequestBytes->Add(bytes); + } + + void OnReply(const ui64 bytes) const { + RepliesCount->Add(1); + ReplyBytes->Add(bytes); + } + + void OnFail(const ui64 bytes) const { + FailsCount->Add(1); + FailBytes->Add(bytes); + } +}; + +} diff --git a/ydb/core/tx/columnshard/blobs_action/counters/storage.cpp b/ydb/core/tx/columnshard/blobs_action/counters/storage.cpp index 4f8b03a9ad48..e7c30dc5ee4f 100644 --- a/ydb/core/tx/columnshard/blobs_action/counters/storage.cpp +++ b/ydb/core/tx/columnshard/blobs_action/counters/storage.cpp @@ -22,6 +22,8 @@ TConsumerCounters::TConsumerCounters(const TString& consumerId, const TStorageCo DeepSubGroup("Consumer", consumerId); ReadCounters = std::make_shared(*this); WriteCounters = std::make_shared(*this); + RemoveDeclareCounters = std::make_shared(*this); + RemoveGCCounters = std::make_shared(*this); } } diff --git a/ydb/core/tx/columnshard/blobs_action/counters/storage.h b/ydb/core/tx/columnshard/blobs_action/counters/storage.h index 8b42b79dfbb6..e92ca28bda20 100644 --- a/ydb/core/tx/columnshard/blobs_action/counters/storage.h +++ b/ydb/core/tx/columnshard/blobs_action/counters/storage.h @@ -1,6 +1,8 @@ #pragma once #include "read.h" #include "write.h" +#include "remove_declare.h" +#include "remove_gc.h" #include #include #include @@ -14,6 +16,8 @@ class TConsumerCounters: public NColumnShard::TCommonCountersOwner { using TBase = NColumnShard::TCommonCountersOwner; YDB_READONLY_DEF(std::shared_ptr, ReadCounters); YDB_READONLY_DEF(std::shared_ptr, WriteCounters); + YDB_READONLY_DEF(std::shared_ptr, RemoveDeclareCounters); + YDB_READONLY_DEF(std::shared_ptr, RemoveGCCounters); public: TConsumerCounters(const TString& consumerId, const TStorageCounters& parent); }; diff --git a/ydb/core/tx/columnshard/blobs_action/counters/ya.make b/ydb/core/tx/columnshard/blobs_action/counters/ya.make index 7e50b3c7f6eb..a3e06c138df9 100644 --- a/ydb/core/tx/columnshard/blobs_action/counters/ya.make +++ b/ydb/core/tx/columnshard/blobs_action/counters/ya.make @@ -4,6 +4,8 @@ SRCS( read.cpp storage.cpp write.cpp + remove_declare.cpp + remove_gc.cpp ) PEERDIR( diff --git a/ydb/core/tx/columnshard/blobs_action/tier/gc.cpp b/ydb/core/tx/columnshard/blobs_action/tier/gc.cpp index 6d311f306c37..d1b509cbef0c 100644 --- a/ydb/core/tx/columnshard/blobs_action/tier/gc.cpp +++ b/ydb/core/tx/columnshard/blobs_action/tier/gc.cpp @@ -24,6 +24,12 @@ bool TGCTask::DoOnCompleteTxAfterCleaning(NColumnShard::TColumnShard& self, cons TActorContext::AsActorContext().Send(self.SelfId(), std::make_unique(taskAction)); return false; } else { + for (auto&& i : DraftBlobIds) { + Counters->OnReply(i.BlobSize()); + } + for (auto&& i : DeleteBlobIds) { + Counters->OnReply(i.BlobSize()); + } return true; } } diff --git a/ydb/core/tx/columnshard/blobs_action/tier/gc.h b/ydb/core/tx/columnshard/blobs_action/tier/gc.h index 5917ca0c3549..cdae1449f2de 100644 --- a/ydb/core/tx/columnshard/blobs_action/tier/gc.h +++ b/ydb/core/tx/columnshard/blobs_action/tier/gc.h @@ -1,5 +1,6 @@ #pragma once #include +#include #include #include #include @@ -13,17 +14,25 @@ class TGCTask: public IBlobsGCAction { YDB_READONLY_DEF(std::deque, DraftBlobIds); YDB_READONLY_DEF(std::deque, DeleteBlobIds); YDB_READONLY_DEF(NWrappers::NExternalStorage::IExternalStorageOperator::TPtr, ExternalStorageOperator); + const std::shared_ptr Counters; protected: virtual void DoOnExecuteTxAfterCleaning(NColumnShard::TColumnShard& self, NColumnShard::TBlobManagerDb& dbBlobs) override; virtual bool DoOnCompleteTxAfterCleaning(NColumnShard::TColumnShard& self, const std::shared_ptr& taskAction) override; public: TGCTask(const TString& storageId, std::deque&& draftBlobIds, std::deque&& deleteBlobIds, - const NWrappers::NExternalStorage::IExternalStorageOperator::TPtr& externalStorageOperator) + const NWrappers::NExternalStorage::IExternalStorageOperator::TPtr& externalStorageOperator, const std::shared_ptr& counters) : TBase(storageId) , DraftBlobIds(std::move(draftBlobIds)) , DeleteBlobIds(std::move(deleteBlobIds)) , ExternalStorageOperator(externalStorageOperator) + , Counters(counters) { + for (auto&& i : DraftBlobIds) { + Counters->OnRequest(i.BlobSize()); + } + for (auto&& i : DeleteBlobIds) { + Counters->OnRequest(i.BlobSize()); + } } }; diff --git a/ydb/core/tx/columnshard/blobs_action/tier/storage.cpp b/ydb/core/tx/columnshard/blobs_action/tier/storage.cpp index a65dfbb7c2da..bf9e02e5f87d 100644 --- a/ydb/core/tx/columnshard/blobs_action/tier/storage.cpp +++ b/ydb/core/tx/columnshard/blobs_action/tier/storage.cpp @@ -30,13 +30,13 @@ std::shared_ptr TOperator::DoStartReadingAction() { return std::make_shared(GetStorageId(), GetCurrentOperator()); } -std::shared_ptr TOperator::DoStartGCAction() const { +std::shared_ptr TOperator::DoStartGCAction(const std::shared_ptr& counters) const { std::deque draftBlobIds; std::deque deleteBlobIds; if (!GCInfo->ExtractForGC(draftBlobIds, deleteBlobIds, 100000)) { return nullptr; } - auto gcTask = std::make_shared(GetStorageId(), std::move(draftBlobIds), std::move(deleteBlobIds), GetCurrentOperator()); + auto gcTask = std::make_shared(GetStorageId(), std::move(draftBlobIds), std::move(deleteBlobIds), GetCurrentOperator(), counters); TActorContext::AsActorContext().Register(new TGarbageCollectionActor(gcTask, TabletActorId)); return gcTask; } diff --git a/ydb/core/tx/columnshard/blobs_action/tier/storage.h b/ydb/core/tx/columnshard/blobs_action/tier/storage.h index b79986f999b5..b153c9b72ecf 100644 --- a/ydb/core/tx/columnshard/blobs_action/tier/storage.h +++ b/ydb/core/tx/columnshard/blobs_action/tier/storage.h @@ -30,7 +30,7 @@ class TOperator: public IBlobsStorageOperator { virtual std::shared_ptr DoStartDeclareRemovingAction() override; virtual std::shared_ptr DoStartWritingAction() override; virtual std::shared_ptr DoStartReadingAction() override; - virtual std::shared_ptr DoStartGCAction() const override; + virtual std::shared_ptr DoStartGCAction(const std::shared_ptr& counters) const override; virtual bool DoLoad(NColumnShard::IBlobManagerDb& dbBlobs) override { dbBlobs.LoadTierLists(GetStorageId(), GCInfo->MutableBlobsToDelete(), GCInfo->MutableDraftBlobIdsToRemove()); return true;