Skip to content

Commit

Permalink
KIKIMR-19215: additional signals
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanmorozov committed Oct 14, 2023
1 parent 3a0ef9c commit b8a327d
Show file tree
Hide file tree
Showing 24 changed files with 198 additions and 14 deletions.
1 change: 1 addition & 0 deletions ydb/core/tx/columnshard/blobs_action/abstract/read.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class IBlobsReadingAction: public ICommonBlobsAction {
THashMap<TBlobRange, TErrorStatus> Fails;
std::shared_ptr<NBlobOperations::TReadCounters> Counters;
bool Started = false;
YDB_ACCESSOR(bool, IsBackgroundProcess, true);
protected:
virtual void DoStartReading(const THashMap<TUnifiedBlobId, THashSet<TBlobRange>>& range) = 0;
void StartReading(THashMap<TUnifiedBlobId, THashSet<TBlobRange>>&& ranges);
Expand Down
1 change: 1 addition & 0 deletions ydb/core/tx/columnshard/blobs_action/abstract/remove.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
6 changes: 6 additions & 0 deletions ydb/core/tx/columnshard/blobs_action/abstract/remove.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <util/generic/hash_set.h>
#include <ydb/core/tx/columnshard/blob.h>
#include <ydb/library/accessor/accessor.h>
#include <ydb/core/tx/columnshard/blobs_action/counters/remove_declare.h>

namespace NKikimr::NColumnShard {
class TColumnShard;
Expand All @@ -14,6 +15,7 @@ namespace NKikimr::NOlap {
class IBlobsDeclareRemovingAction: public ICommonBlobsAction {
private:
using TBase = ICommonBlobsAction;
std::shared_ptr<NBlobOperations::TRemoveDeclareCounters> Counters;
YDB_READONLY_DEF(THashSet<TUnifiedBlobId>, DeclaredBlobs);
protected:
virtual void DoDeclareRemove(const TUnifiedBlobId& blobId) = 0;
Expand All @@ -26,6 +28,10 @@ class IBlobsDeclareRemovingAction: public ICommonBlobsAction {

}

void SetCounters(const std::shared_ptr<NBlobOperations::TRemoveDeclareCounters>& counters) {
Counters = counters;
}

void DeclareRemove(const TUnifiedBlobId& blobId);
void OnExecuteTxAfterRemoving(NColumnShard::TColumnShard& self, NColumnShard::TBlobManagerDb& dbBlobs, const bool success) {
return DoOnExecuteTxAfterRemoving(self, dbBlobs, success);
Expand Down
15 changes: 9 additions & 6 deletions ydb/core/tx/columnshard/blobs_action/abstract/storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include <ydb/core/tx/columnshard/blobs_action/blob_manager_db.h>
#include <ydb/core/tx/columnshard/blobs_action/counters/storage.h>
#include <ydb/core/tx/columnshard/blobs_action/counters/remove_gc.h>
#include <ydb/library/accessor/accessor.h>

namespace NKikimr::NColumnShard {
Expand Down Expand Up @@ -47,9 +48,9 @@ class IBlobsStorageOperator {
return "";
}

virtual std::shared_ptr<IBlobsGCAction> DoStartGCAction() const = 0;
std::shared_ptr<IBlobsGCAction> StartGCAction() const {
return DoStartGCAction();
virtual std::shared_ptr<IBlobsGCAction> DoStartGCAction(const std::shared_ptr<NBlobOperations::TRemoveGCCounters>& counters) const = 0;
std::shared_ptr<IBlobsGCAction> StartGCAction(const std::shared_ptr<NBlobOperations::TRemoveGCCounters>& counters) const {
return DoStartGCAction(counters);
}

public:
Expand All @@ -76,8 +77,10 @@ class IBlobsStorageOperator {
return DoOnTieringModified(tiers);
}

std::shared_ptr<IBlobsDeclareRemovingAction> StartDeclareRemovingAction(const TString& /*consumerId*/) {
return DoStartDeclareRemovingAction();
std::shared_ptr<IBlobsDeclareRemovingAction> StartDeclareRemovingAction(const TString& consumerId) {
auto result = DoStartDeclareRemovingAction();
result->SetCounters(Counters->GetConsumerCounter(consumerId)->GetRemoveDeclareCounters());
return result;
}
std::shared_ptr<IBlobsWritingAction> StartWritingAction(const TString& consumerId) {
auto result = DoStartWritingAction();
Expand All @@ -96,7 +99,7 @@ class IBlobsStorageOperator {
if (Stopped) {
return false;
}
auto task = StartGCAction();
auto task = StartGCAction(Counters->GetConsumerCounter("GC")->GetRemoveGCCounters());
if (!task) {
return false;
}
Expand Down
9 changes: 8 additions & 1 deletion ydb/core/tx/columnshard/blobs_action/bs/gc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -83,7 +88,9 @@ THashMap<ui32, std::unique_ptr<NKikimr::TEvBlobStorage::TEvCollectGarbage>> TGCT
new TVector<TLogoBlobID>(gl.second.KeepList.begin(), gl.second.KeepList.end()),
new TVector<TLogoBlobID>(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();
}
Expand Down
6 changes: 6 additions & 0 deletions ydb/core/tx/columnshard/blobs_action/bs/gc.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include <ydb/core/tx/columnshard/blob_cache.h>
#include <ydb/core/tx/columnshard/blobs_action/abstract/gc.h>
#include <ydb/core/tx/columnshard/blobs_action/counters/remove_gc.h>
#include <ydb/core/tx/columnshard/blob_manager.h>

namespace NKikimr::NOlap::NBlobOperations::NBlobStorage {
Expand All @@ -23,6 +24,7 @@ class TGCTask: public IBlobsGCAction {
std::deque<TUnifiedBlobId> KeepsToErase;
std::deque<TUnifiedBlobId> DeletesToErase;
std::shared_ptr<NColumnShard::TBlobManager> Manager;
std::shared_ptr<TRemoveGCCounters> Counters;
protected:
virtual void DoOnExecuteTxAfterCleaning(NColumnShard::TColumnShard& self, NColumnShard::TBlobManagerDb& dbBlobs) override;
virtual bool DoOnCompleteTxAfterCleaning(NColumnShard::TColumnShard& self, const std::shared_ptr<IBlobsGCAction>& taskAction) override;
Expand All @@ -31,6 +33,10 @@ class TGCTask: public IBlobsGCAction {
return ListsByGroupId.empty();
}

void SetCounters(const std::shared_ptr<TRemoveGCCounters>& counters) {
Counters = counters;
}

TGCTask(const TString& storageId, TGCListsByGroup&& listsByGroupId, const NColumnShard::TGenStep& collectGenStepInFlight, std::deque<TUnifiedBlobId>&& keepsToErase, std::deque<TUnifiedBlobId>&& deletesToErase,
const std::shared_ptr<NColumnShard::TBlobManager>& manager);

Expand Down
2 changes: 1 addition & 1 deletion ydb/core/tx/columnshard/blobs_action/bs/read.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class TReadingAction: public IBlobsReadingAction {
protected:
virtual void DoStartReading(const THashMap<TUnifiedBlobId, THashSet<TBlobRange>>& 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<TBlobRange> 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());
Expand Down
3 changes: 2 additions & 1 deletion ydb/core/tx/columnshard/blobs_action/bs/storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ std::shared_ptr<NKikimr::NOlap::IBlobsReadingAction> TOperator::DoStartReadingAc
return std::make_shared<TReadingAction>(GetStorageId(), BlobCacheActorId);
}

std::shared_ptr<IBlobsGCAction> TOperator::DoStartGCAction() const {
std::shared_ptr<IBlobsGCAction> TOperator::DoStartGCAction(const std::shared_ptr<TRemoveGCCounters>& 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());
Expand Down
2 changes: 1 addition & 1 deletion ydb/core/tx/columnshard/blobs_action/bs/storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class TOperator: public IBlobsStorageOperator {
virtual std::shared_ptr<IBlobsDeclareRemovingAction> DoStartDeclareRemovingAction() override;
virtual std::shared_ptr<IBlobsWritingAction> DoStartWritingAction() override;
virtual std::shared_ptr<IBlobsReadingAction> DoStartReadingAction() override;
virtual std::shared_ptr<IBlobsGCAction> DoStartGCAction() const override;
virtual std::shared_ptr<IBlobsGCAction> DoStartGCAction(const std::shared_ptr<TRemoveGCCounters>& counters) const override;
virtual bool DoLoad(NColumnShard::IBlobManagerDb& dbBlobs) override {
return Manager->LoadState(dbBlobs);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
23 changes: 23 additions & 0 deletions ydb/core/tx/columnshard/blobs_action/counters/remove_declare.cpp
Original file line number Diff line number Diff line change
@@ -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));
}

}
47 changes: 47 additions & 0 deletions ydb/core/tx/columnshard/blobs_action/counters/remove_declare.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#pragma once
#include <library/cpp/monlib/dynamic_counters/counters.h>
#include <ydb/core/tx/columnshard/counters/common/owner.h>

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);
}
};

}
19 changes: 19 additions & 0 deletions ydb/core/tx/columnshard/blobs_action/counters/remove_gc.cpp
Original file line number Diff line number Diff line change
@@ -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");
}

}
39 changes: 39 additions & 0 deletions ydb/core/tx/columnshard/blobs_action/counters/remove_gc.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#pragma once
#include <library/cpp/monlib/dynamic_counters/counters.h>
#include <ydb/core/tx/columnshard/counters/common/owner.h>

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);
}
};

}
2 changes: 2 additions & 0 deletions ydb/core/tx/columnshard/blobs_action/counters/storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ TConsumerCounters::TConsumerCounters(const TString& consumerId, const TStorageCo
DeepSubGroup("Consumer", consumerId);
ReadCounters = std::make_shared<TReadCounters>(*this);
WriteCounters = std::make_shared<TWriteCounters>(*this);
RemoveDeclareCounters = std::make_shared<TRemoveDeclareCounters>(*this);
RemoveGCCounters = std::make_shared<TRemoveGCCounters>(*this);
}

}
4 changes: 4 additions & 0 deletions ydb/core/tx/columnshard/blobs_action/counters/storage.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#pragma once
#include "read.h"
#include "write.h"
#include "remove_declare.h"
#include "remove_gc.h"
#include <ydb/core/tx/columnshard/counters/common/owner.h>
#include <library/cpp/monlib/dynamic_counters/counters.h>
#include <util/generic/hash.h>
Expand All @@ -14,6 +16,8 @@ class TConsumerCounters: public NColumnShard::TCommonCountersOwner {
using TBase = NColumnShard::TCommonCountersOwner;
YDB_READONLY_DEF(std::shared_ptr<TReadCounters>, ReadCounters);
YDB_READONLY_DEF(std::shared_ptr<TWriteCounters>, WriteCounters);
YDB_READONLY_DEF(std::shared_ptr<TRemoveDeclareCounters>, RemoveDeclareCounters);
YDB_READONLY_DEF(std::shared_ptr<TRemoveGCCounters>, RemoveGCCounters);
public:
TConsumerCounters(const TString& consumerId, const TStorageCounters& parent);
};
Expand Down
2 changes: 2 additions & 0 deletions ydb/core/tx/columnshard/blobs_action/counters/ya.make
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ SRCS(
read.cpp
storage.cpp
write.cpp
remove_declare.cpp
remove_gc.cpp
)

PEERDIR(
Expand Down
6 changes: 6 additions & 0 deletions ydb/core/tx/columnshard/blobs_action/tier/gc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ bool TGCTask::DoOnCompleteTxAfterCleaning(NColumnShard::TColumnShard& self, cons
TActorContext::AsActorContext().Send(self.SelfId(), std::make_unique<NColumnShard::TEvPrivate::TEvGarbageCollectionFinished>(taskAction));
return false;
} else {
for (auto&& i : DraftBlobIds) {
Counters->OnReply(i.BlobSize());
}
for (auto&& i : DeleteBlobIds) {
Counters->OnReply(i.BlobSize());
}
return true;
}
}
Expand Down
Loading

0 comments on commit b8a327d

Please sign in to comment.