diff options
author | abcdef <akotov@ydb.tech> | 2023-07-04 10:21:42 +0300 |
---|---|---|
committer | abcdef <akotov@ydb.tech> | 2023-07-04 10:21:42 +0300 |
commit | 6b1fffd64f2a49f05aa5beba087969c8df16f0d4 (patch) | |
tree | 1bb4fbd328adff491e29c78340ebe83520799749 | |
parent | 05cad0346bee58f4820a0f48bfd056937c7b7fcd (diff) | |
download | ydb-6b1fffd64f2a49f05aa5beba087969c8df16f0d4.tar.gz |
statistics are not taken into account during warm-up
показатели статистики не учитываются во время прогрева
-rw-r--r-- | ydb/public/lib/ydb_cli/commands/topic_workload/topic_workload_stats_collector.cpp | 35 | ||||
-rw-r--r-- | ydb/public/lib/ydb_cli/commands/topic_workload/topic_workload_stats_collector.h | 8 |
2 files changed, 24 insertions, 19 deletions
diff --git a/ydb/public/lib/ydb_cli/commands/topic_workload/topic_workload_stats_collector.cpp b/ydb/public/lib/ydb_cli/commands/topic_workload/topic_workload_stats_collector.cpp index 57881a1b8d9..22e6d618edb 100644 --- a/ydb/public/lib/ydb_cli/commands/topic_workload/topic_workload_stats_collector.cpp +++ b/ydb/public/lib/ydb_cli/commands/topic_workload/topic_workload_stats_collector.cpp @@ -62,18 +62,22 @@ void TTopicWorkloadStatsCollector::PrintHeader(bool total) const { } void TTopicWorkloadStatsCollector::PrintWindowStatsLoop() { - auto StartTime = Now(); - auto StopTime = StartTime + TDuration::Seconds(TotalSec + 1); + auto startTime = Now(); + WarmupTime = startTime + TDuration::Seconds(WarmupSec); + auto stopTime = startTime + TDuration::Seconds(TotalSec + 1); int windowIt = 1; auto windowDuration = TDuration::Seconds(WindowSec); - while (Now() < StopTime && !*ErrorFlag) { - if (Now() > StartTime + windowIt * windowDuration && !*ErrorFlag) { - CollectThreadEvents(windowIt); + while (Now() < stopTime && !*ErrorFlag) { + auto windowTime = [startTime, windowDuration](int index) { + return startTime + index * windowDuration; + }; + if (Now() > windowTime(windowIt) && !*ErrorFlag) { + CollectThreadEvents(); PrintWindowStats(windowIt++); } - Sleep(std::max(TDuration::Zero(), Now() - StartTime - windowIt * windowDuration)); + Sleep(std::max(TDuration::Zero(), Now() - windowTime(windowIt))); } - CollectThreadEvents(windowIt); + CollectThreadEvents(); } void TTopicWorkloadStatsCollector::PrintWindowStats(ui32 windowIt) { @@ -114,22 +118,19 @@ void TTopicWorkloadStatsCollector::PrintStats(TMaybe<ui32> windowIt) const { Cout << Endl; } -void TTopicWorkloadStatsCollector::CollectThreadEvents(ui32 windowIt) +void TTopicWorkloadStatsCollector::CollectThreadEvents() { - CollectThreadEvents(windowIt, WriterEventQueues); - CollectThreadEvents(windowIt, ReaderEventQueues); - CollectThreadEvents(windowIt, LagEventQueues); + CollectThreadEvents(WriterEventQueues); + CollectThreadEvents(ReaderEventQueues); + CollectThreadEvents(LagEventQueues); } template<class T> -void TTopicWorkloadStatsCollector::CollectThreadEvents(ui32 windowIt, TEventQueues<T>& queues) +void TTopicWorkloadStatsCollector::CollectThreadEvents(TEventQueues<T>& queues) { for (auto& queue : queues) { THolder<T> event; while (queue->Dequeue(&event)) { - if (windowIt <= WarmupSec) { - continue; - } WindowStats->AddEvent(*event); TotalStats.AddEvent(*event); } @@ -162,5 +163,7 @@ void TTopicWorkloadStatsCollector::AddLagEvent(size_t readerIdx, const TTopicWor template<class T> void TTopicWorkloadStatsCollector::AddEvent(size_t index, TEventQueues<T>& queues, const T& event) { - queues[index]->Enqueue(MakeHolder<T>(event)); + if ((WarmupTime != TInstant()) && (Now() >= WarmupTime)) { + queues[index]->Enqueue(MakeHolder<T>(event)); + } } diff --git a/ydb/public/lib/ydb_cli/commands/topic_workload/topic_workload_stats_collector.h b/ydb/public/lib/ydb_cli/commands/topic_workload/topic_workload_stats_collector.h index 2a30cb815bd..eaa391f0ead 100644 --- a/ydb/public/lib/ydb_cli/commands/topic_workload/topic_workload_stats_collector.h +++ b/ydb/public/lib/ydb_cli/commands/topic_workload/topic_workload_stats_collector.h @@ -33,12 +33,12 @@ namespace NYdb { template<class T> using TEventQueues = std::vector<THolder<TAutoLockFreeQueue<T>>>; - void CollectThreadEvents(ui32 windowIt); + void CollectThreadEvents(); template<class T> - void CollectThreadEvents(ui32 windowIt, TEventQueues<T>& queues); + void CollectThreadEvents(TEventQueues<T>& queues); template<class T> - static void AddEvent(size_t index, TEventQueues<T>& queues, const T& event); + void AddEvent(size_t index, TEventQueues<T>& queues, const T& event); void PrintWindowStats(ui32 windowIt); void PrintStats(TMaybe<ui32> windowIt) const; @@ -63,6 +63,8 @@ namespace NYdb { THolder<TTopicWorkloadStats> WindowStats; TTopicWorkloadStats TotalStats; + + TInstant WarmupTime; }; } } |