aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorivanmorozov <ivanmorozov@yandex-team.com>2023-06-11 19:34:47 +0300
committerivanmorozov <ivanmorozov@yandex-team.com>2023-06-11 19:34:47 +0300
commit90abfcac34c50a1d082fd4e6f6e237a4b56d31c5 (patch)
treed23fe42084f3fa341969877b41cb8b2ad551f9cd
parent8d108cb49e53dba8299de246815caee5abc44585 (diff)
downloadydb-90abfcac34c50a1d082fd4e6f6e237a4b56d31c5.tar.gz
list instead of deque for signals
-rw-r--r--ydb/core/tx/columnshard/counters/columnshard.h8
-rw-r--r--ydb/core/tx/columnshard/counters/common/agent.cpp31
-rw-r--r--ydb/core/tx/columnshard/counters/common/agent.h5
-rw-r--r--ydb/core/tx/columnshard/counters/common/client.cpp10
-rw-r--r--ydb/core/tx/columnshard/counters/common/client.h14
-rw-r--r--ydb/core/tx/columnshard/counters/common/owner.cpp2
-rw-r--r--ydb/core/tx/columnshard/counters/engine_logs.h4
-rw-r--r--ydb/core/tx/columnshard/counters/insert_table.h22
8 files changed, 48 insertions, 48 deletions
diff --git a/ydb/core/tx/columnshard/counters/columnshard.h b/ydb/core/tx/columnshard/counters/columnshard.h
index af9aed36ff..dea6ad256e 100644
--- a/ydb/core/tx/columnshard/counters/columnshard.h
+++ b/ydb/core/tx/columnshard/counters/columnshard.h
@@ -36,13 +36,13 @@ private:
std::shared_ptr<TValueAggregationClient> SplitCompactionGranulePortionsCount;
public:
void OnInternalCompactionInfo(const ui64 bytes, const ui32 portionsCount) const {
- InternalCompactionGranuleBytes->Set(bytes);
- InternalCompactionGranulePortionsCount->Set(portionsCount);
+ InternalCompactionGranuleBytes->SetValue(bytes);
+ InternalCompactionGranulePortionsCount->SetValue(portionsCount);
}
void OnSplitCompactionInfo(const ui64 bytes, const ui32 portionsCount) const {
- SplitCompactionGranuleBytes->Set(bytes);
- SplitCompactionGranulePortionsCount->Set(portionsCount);
+ SplitCompactionGranuleBytes->SetValue(bytes);
+ SplitCompactionGranulePortionsCount->SetValue(portionsCount);
}
void OnOverloadInsertTable(const ui64 size) const {
diff --git a/ydb/core/tx/columnshard/counters/common/agent.cpp b/ydb/core/tx/columnshard/counters/common/agent.cpp
index e34fe416ca..ea431b5943 100644
--- a/ydb/core/tx/columnshard/counters/common/agent.cpp
+++ b/ydb/core/tx/columnshard/counters/common/agent.cpp
@@ -12,20 +12,20 @@ TValueAggregationAgent::TValueAggregationAgent(const TString& signalName, const
}
bool TValueAggregationAgent::CalcAggregations(i64& sum, i64& minValue, i64& maxValue) const {
- const ui32 count = Values.size();
- if (!count) {
+ if (Values.empty()) {
return false;
}
sum = 0;
- minValue = Values.front();
- maxValue = Values.front();
- for (ui32 i = 0; i < count; ++i) {
- sum += Values[i];
- if (minValue > Values[i]) {
- minValue = Values[i];
+ minValue = Values.front()->GetValue();
+ maxValue = Values.front()->GetValue();
+ for (auto&& i : Values) {
+ const i64 v = i->GetValue();
+ sum += v;
+ if (minValue > v) {
+ minValue = v;
}
- if (maxValue < Values[i]) {
- maxValue = Values[i];
+ if (maxValue < v) {
+ maxValue = v;
}
}
return true;
@@ -52,13 +52,16 @@ void TValueAggregationAgent::ResendStatus() const {
}
std::shared_ptr<NKikimr::NColumnShard::TValueAggregationClient> TValueAggregationAgent::GetClient(std::shared_ptr<TValueAggregationAgent> selfPtr) {
- return std::make_shared<TValueAggregationClient>(selfPtr);
+ TGuard<TMutex> g(Mutex);
+ auto it = Values.emplace(Values.end(), nullptr);
+ auto result = std::make_shared<TValueAggregationClient>(selfPtr, it);
+ *it = result.get();
+ return result;
}
-i64* TValueAggregationAgent::RegisterValue(const i64 zeroValue /*= 0*/) {
+void TValueAggregationAgent::UnregisterClient(std::list<TValueAggregationClient*>::iterator it) {
TGuard<TMutex> g(Mutex);
- Values.emplace_back(zeroValue);
- return &Values.back();
+ Values.erase(it);
}
}
diff --git a/ydb/core/tx/columnshard/counters/common/agent.h b/ydb/core/tx/columnshard/counters/common/agent.h
index c10ecb5dee..7446b4fdff 100644
--- a/ydb/core/tx/columnshard/counters/common/agent.h
+++ b/ydb/core/tx/columnshard/counters/common/agent.h
@@ -25,7 +25,7 @@ private:
::NMonitoring::TDynamicCounters::TCounterPtr ValueSignalSum;
::NMonitoring::TDynamicCounters::TCounterPtr ValueSignalMin;
::NMonitoring::TDynamicCounters::TCounterPtr ValueSignalMax;
- std::deque<i64> Values;
+ std::list<TValueAggregationClient*> Values;
TMutex Mutex;
bool CalcAggregations(i64& sum, i64& minValue, i64& maxValue) const;
@@ -33,9 +33,8 @@ private:
public:
TValueAggregationAgent(const TString& signalName, const TCommonCountersOwner& signalsOwner);
-
- i64* RegisterValue(const i64 zeroValue = 0);
void ResendStatus() const;
+ void UnregisterClient(std::list<TValueAggregationClient*>::iterator it);
std::shared_ptr<TValueAggregationClient> GetClient(std::shared_ptr<TValueAggregationAgent> selfPtr);
};
diff --git a/ydb/core/tx/columnshard/counters/common/client.cpp b/ydb/core/tx/columnshard/counters/common/client.cpp
index 71e18722a6..76718b96a7 100644
--- a/ydb/core/tx/columnshard/counters/common/client.cpp
+++ b/ydb/core/tx/columnshard/counters/common/client.cpp
@@ -3,19 +3,15 @@
namespace NKikimr::NColumnShard {
-TValueAggregationClient::TValueAggregationClient(std::shared_ptr<TValueAggregationAgent> owner)
+TValueAggregationClient::TValueAggregationClient(std::shared_ptr<TValueAggregationAgent> owner, std::list<TValueAggregationClient*>::iterator it)
: Owner(owner)
- , ValuePtr(Owner->RegisterValue(0))
+ , PositionIterator(it)
{
}
-void TValueAggregationClient::Set(const i64 value) const {
- *ValuePtr = value;
-}
-
TValueAggregationClient::~TValueAggregationClient() {
- Set(0);
+ Owner->UnregisterClient(PositionIterator);
}
}
diff --git a/ydb/core/tx/columnshard/counters/common/client.h b/ydb/core/tx/columnshard/counters/common/client.h
index f9fba2f5c2..f935af1ddf 100644
--- a/ydb/core/tx/columnshard/counters/common/client.h
+++ b/ydb/core/tx/columnshard/counters/common/client.h
@@ -1,19 +1,21 @@
#pragma once
-#include <memory>
+#include <ydb/library/accessor/accessor.h>
#include <util/system/types.h>
+#include <util/generic/noncopyable.h>
+#include <list>
+#include <memory>
namespace NKikimr::NColumnShard {
class TValueAggregationAgent;
-class TValueAggregationClient {
+class TValueAggregationClient: TNonCopyable {
private:
std::shared_ptr<TValueAggregationAgent> Owner;
- i64* ValuePtr = nullptr;
+ std::list<TValueAggregationClient*>::iterator PositionIterator;
+ YDB_ACCESSOR(i64, Value, 0);
public:
- TValueAggregationClient(std::shared_ptr<TValueAggregationAgent> owner);
+ TValueAggregationClient(std::shared_ptr<TValueAggregationAgent> owner, std::list<TValueAggregationClient*>::iterator it);
~TValueAggregationClient();
-
- void Set(const i64 value) const;
};
}
diff --git a/ydb/core/tx/columnshard/counters/common/owner.cpp b/ydb/core/tx/columnshard/counters/common/owner.cpp
index d674fcf231..0a86a6896b 100644
--- a/ydb/core/tx/columnshard/counters/common/owner.cpp
+++ b/ydb/core/tx/columnshard/counters/common/owner.cpp
@@ -37,7 +37,7 @@ std::shared_ptr<TValueAggregationAgent> TCommonCountersOwner::GetValueAutoAggreg
std::shared_ptr<TValueAggregationClient> TCommonCountersOwner::GetValueAutoAggregationsClient(const TString& name) const {
std::shared_ptr<TValueAggregationAgent> agent = NPrivate::TAggregationsController::GetAggregation(name, *this);
- return std::make_shared<TValueAggregationClient>(agent);
+ return agent->GetClient(agent);
}
}
diff --git a/ydb/core/tx/columnshard/counters/engine_logs.h b/ydb/core/tx/columnshard/counters/engine_logs.h
index 5c64942bc1..6bed61e0f1 100644
--- a/ydb/core/tx/columnshard/counters/engine_logs.h
+++ b/ydb/core/tx/columnshard/counters/engine_logs.h
@@ -38,8 +38,8 @@ public:
}
void OnPortionsInfo(const TBaseGranuleDataClassSummary& dataInfo) const {
- PortionsSize->Set(dataInfo.GetPortionsSize());
- PortionsCount->Set(dataInfo.GetPortionsCount());
+ PortionsSize->SetValue(dataInfo.GetPortionsSize());
+ PortionsCount->SetValue(dataInfo.GetPortionsCount());
}
};
diff --git a/ydb/core/tx/columnshard/counters/insert_table.h b/ydb/core/tx/columnshard/counters/insert_table.h
index 30dee6ba64..92a31cb9ea 100644
--- a/ydb/core/tx/columnshard/counters/insert_table.h
+++ b/ydb/core/tx/columnshard/counters/insert_table.h
@@ -8,35 +8,35 @@ namespace NKikimr::NColumnShard {
class TPathIdClientCounters {
private:
using TBase = TCommonCountersOwner;
- const std::shared_ptr<TValueAggregationClient> PathIdCommittedBytes;
- const std::shared_ptr<TValueAggregationClient> PathIdCommittedChunks;
+ const std::shared_ptr<TValueAggregationClient> PathIdBytes;
+ const std::shared_ptr<TValueAggregationClient> PathIdChunks;
public:
TPathIdClientCounters(std::shared_ptr<TValueAggregationClient> pathIdCommittedBytes, std::shared_ptr<TValueAggregationClient> pathIdCommittedChunks)
- : PathIdCommittedBytes(pathIdCommittedBytes)
- , PathIdCommittedChunks(pathIdCommittedChunks) {
+ : PathIdBytes(pathIdCommittedBytes)
+ , PathIdChunks(pathIdCommittedChunks) {
}
void OnPathIdDataInfo(const ui64 bytes, const ui32 chunks) const {
- PathIdCommittedBytes->Set(bytes);
- PathIdCommittedChunks->Set(chunks);
+ PathIdBytes->SetValue(bytes);
+ PathIdChunks->SetValue(chunks);
}
};
class TPathIdInfoCounters: public TCommonCountersOwner {
private:
using TBase = TCommonCountersOwner;
- const std::shared_ptr<TValueAggregationAgent> PathIdCommittedBytes;
- const std::shared_ptr<TValueAggregationAgent> PathIdCommittedChunks;
+ const std::shared_ptr<TValueAggregationAgent> PathIdBytes;
+ const std::shared_ptr<TValueAggregationAgent> PathIdChunks;
public:
TPathIdInfoCounters(const TString& countersName, const TString& dataName)
: TBase(countersName)
- , PathIdCommittedBytes(TBase::GetValueAutoAggregations("PathId/" + dataName + "/Bytes"))
- , PathIdCommittedChunks(TBase::GetValueAutoAggregations("PathId/" + dataName + "/Chunks"))
+ , PathIdBytes(TBase::GetValueAutoAggregations("PathId/" + dataName + "/Bytes"))
+ , PathIdChunks(TBase::GetValueAutoAggregations("PathId/" + dataName + "/Chunks"))
{
}
TPathIdClientCounters GetClient() const {
- return TPathIdClientCounters(PathIdCommittedBytes->GetClient(PathIdCommittedBytes), PathIdCommittedChunks->GetClient(PathIdCommittedChunks));
+ return TPathIdClientCounters(PathIdBytes->GetClient(PathIdBytes), PathIdChunks->GetClient(PathIdChunks));
}
};