aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorxenoxeno <xeno@ydb.tech>2022-08-29 16:27:09 +0300
committerxenoxeno <xeno@ydb.tech>2022-08-29 16:27:09 +0300
commit3e9641dc4ea2dc38f23b01096992636f97a3dd7f (patch)
treeb954683e2af894c645e3e7a7cbb0513e1a440c3e
parente31803f9523c2d40aabd97d66f9cc6ea6e8b54e3 (diff)
downloadydb-3e9641dc4ea2dc38f23b01096992636f97a3dd7f.tar.gz
add metrics for sequences sizes
-rw-r--r--ydb/core/mind/hive/sequencer.cpp18
-rw-r--r--ydb/core/mind/hive/sequencer.h2
-rw-r--r--ydb/core/mind/hive/tx__create_tablet.cpp2
-rw-r--r--ydb/core/mind/hive/tx__load_everything.cpp2
-rw-r--r--ydb/core/protos/counters_hive.proto2
5 files changed, 13 insertions, 13 deletions
diff --git a/ydb/core/mind/hive/sequencer.cpp b/ydb/core/mind/hive/sequencer.cpp
index 3d3a5b3f08..c0839361d8 100644
--- a/ydb/core/mind/hive/sequencer.cpp
+++ b/ydb/core/mind/hive/sequencer.cpp
@@ -12,6 +12,7 @@ bool TSequenceGenerator::AddFreeSequence(TOwnerType owner, TSequencer::TSequence
if (inserted) {
if (!sequence.Empty()) {
FreeSequences.emplace_back(owner);
+ FreeSize_ += sequence.Size();
}
++FreeSequencesIndex;
}
@@ -24,6 +25,7 @@ void TSequenceGenerator::AddAllocatedSequence(TOwnerType owner, TSequence sequen
{
auto [it, inserted] = AllocatedSequences.emplace(sequence, owner);
Y_VERIFY(inserted);
+ AllocatedSize_ += sequence.Size();
}
{
auto [it, inserted] = SequenceByOwner.emplace(owner, sequence);
@@ -64,6 +66,7 @@ TSequencer::TSequence TSequenceGenerator::AllocateSequence(TSequencer::TOwnerTyp
if (itSequence->second.Empty()) {
FreeSequences.pop_front();
}
+ FreeSize_ -= result.Size();
if (size > 1) {
AddAllocatedSequence(owner, result);
modified.emplace_back(owner);
@@ -100,22 +103,11 @@ TSequencer::TOwnerType TSequenceGenerator::GetOwner(TSequencer::TElementType ele
}
size_t TSequenceGenerator::FreeSize() const {
- size_t size = 0;
- for (const auto& owner : FreeSequences) {
- auto itSeq = SequenceByOwner.find(owner);
- if (itSeq != SequenceByOwner.end()) {
- size += itSeq->second.Size();
- }
- }
- return size;
+ return FreeSize_;
}
size_t TSequenceGenerator::AllocatedSequencesSize() const {
- size_t size = 0;
- for (const auto& [seq, owner] : AllocatedSequences) {
- size += seq.Size();
- }
- return size;
+ return AllocatedSize_;
}
size_t TSequenceGenerator::AllocatedSequencesCount() const {
diff --git a/ydb/core/mind/hive/sequencer.h b/ydb/core/mind/hive/sequencer.h
index 3b3aa8a90a..9ff38a9e76 100644
--- a/ydb/core/mind/hive/sequencer.h
+++ b/ydb/core/mind/hive/sequencer.h
@@ -114,6 +114,8 @@ protected:
std::map<TSequence, TOwnerType> AllocatedSequences;
std::list<TOwnerType> FreeSequences;
size_t FreeSequencesIndex = 0;
+ size_t FreeSize_ = 0;
+ size_t AllocatedSize_ = 0;
};
// to keep ownership of sequences
diff --git a/ydb/core/mind/hive/tx__create_tablet.cpp b/ydb/core/mind/hive/tx__create_tablet.cpp
index 5606a10f22..07b085ca98 100644
--- a/ydb/core/mind/hive/tx__create_tablet.cpp
+++ b/ydb/core/mind/hive/tx__create_tablet.cpp
@@ -482,6 +482,8 @@ public:
const TOwnerIdxType::TValueType ownerIdx(OwnerId, OwnerIdx);
BLOG_D("THive::TTxCreateTablet::Complete " << ownerIdx << " TabletId: " << TabletId << " SideEffects: " << SideEffects);
SideEffects.Complete(ctx);
+ Self->TabletCounters->Simple()[NHive::COUNTER_SEQUENCE_FREE].Set(Self->Sequencer.FreeSize());
+ Self->TabletCounters->Simple()[NHive::COUNTER_SEQUENCE_ALLOCATED].Set(Self->Sequencer.AllocatedSequencesSize());
}
};
diff --git a/ydb/core/mind/hive/tx__load_everything.cpp b/ydb/core/mind/hive/tx__load_everything.cpp
index 9dfe745d5c..6a16716b2e 100644
--- a/ydb/core/mind/hive/tx__load_everything.cpp
+++ b/ydb/core/mind/hive/tx__load_everything.cpp
@@ -655,6 +655,8 @@ public:
Self->Become(&TSelf::StateWork);
Self->SetCounterTabletsTotal(tabletsTotal);
+ Self->TabletCounters->Simple()[NHive::COUNTER_SEQUENCE_FREE].Set(Self->Sequencer.FreeSize());
+ Self->TabletCounters->Simple()[NHive::COUNTER_SEQUENCE_ALLOCATED].Set(Self->Sequencer.AllocatedSequencesSize());
Self->MigrationState = NKikimrHive::EMigrationState::MIGRATION_READY;
ctx.Send(Self->SelfId(), new TEvPrivate::TEvBootTablets());
diff --git a/ydb/core/protos/counters_hive.proto b/ydb/core/protos/counters_hive.proto
index bc7322f46b..30cd0552eb 100644
--- a/ydb/core/protos/counters_hive.proto
+++ b/ydb/core/protos/counters_hive.proto
@@ -20,6 +20,8 @@ enum ESimpleCounters {
COUNTER_WAITQUEUE_SIZE = 10 [(CounterOpts) = {Name: "WaitQueueSize"}];
COUNTER_BALANCE_USAGE_MIN = 11 [(CounterOpts) = {Name: "BalanceUsageMin"}];
COUNTER_BALANCE_USAGE_MAX = 12 [(CounterOpts) = {Name: "BalanceUsageMax"}];
+ COUNTER_SEQUENCE_FREE = 13 [(CounterOpts) = {Name: "SequenceFree"}];
+ COUNTER_SEQUENCE_ALLOCATED = 14 [(CounterOpts) = {Name: "SequenceAllocated"}];
}
enum ECumulativeCounters {