Skip to content

Commit 31faa1f

Browse files
committed
reorganize scan counter (wip: need to fix compilation)
1 parent 119d2fe commit 31faa1f

File tree

9 files changed

+29
-24
lines changed

9 files changed

+29
-24
lines changed

ydb/core/tx/columnshard/columnshard.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -160,18 +160,12 @@ void TColumnShard::Handle(TEvPrivate::TEvReadFinished::TPtr& ev, const TActorCon
160160
InFlightReadsTracker.RemoveInFlightRequest(ev->Get()->RequestCookie, index);
161161

162162
ui64 txId = ev->Get()->TxId;
163-
bool success = ev->Get()->Success;
164163
if (ScanTxInFlight.contains(txId)) {
165164
TDuration duration = TAppData::TimeProvider->Now() - ScanTxInFlight[txId];
166165
Stats.GetTabletCounters().IncCounter(COUNTER_SCAN_LATENCY, duration);
167166
ScanTxInFlight.erase(txId);
168167
Stats.GetTabletCounters().SetCounter(COUNTER_SCAN_IN_FLY, ScanTxInFlight.size());
169168
Stats.GetTabletCounters().IncCounter(COUNTER_IMMEDIATE_TX_COMPLETED);
170-
if (success) {
171-
Stats.GetTabletCounters().IncCounter(COUNTER_READ_SUCCESS);
172-
} else {
173-
Stats.GetTabletCounters().IncCounter(COUNTER_READ_FAIL);
174-
}
175169
}
176170
}
177171

@@ -333,8 +327,8 @@ void TColumnShard::FillOlapStats(
333327
statsBuilder.FillColumnTableStats(Stats.GetColumnTableCounters());
334328
statsBuilder.FillTabletStats(Stats.GetTabletCounters());
335329
statsBuilder.FillBackgroundControllerStats(Stats.GetBackgroundControllerCounters());
330+
statsBuilder.FillScanCountersStats(Stats.GetScanCounters());
336331
statsBuilder.FillExecutorStats(*Executor());
337-
statsBuilder.FillTxCompleteLag(GetTxCompleteLag());
338332
if (TablesManager.HasPrimaryIndex()) {
339333
statsBuilder.FillColumnEngineStats(TablesManager.MutablePrimaryIndex().GetTotalStats());
340334
}
@@ -366,8 +360,8 @@ void TColumnShard::FillColumnTableStats(
366360
statsBuilder.FillColumnTableStats(Stats.GetColumnTableCounters().GetPathIdCounter(pathId));
367361
statsBuilder.FillTabletStats(Stats.GetTabletCounters());
368362
statsBuilder.FillBackgroundControllerStats(Stats.GetBackgroundControllerCounters(), pathId);
363+
statsBuilder.FillScanCountersStats(Stats.GetScanCounters());
369364
statsBuilder.FillExecutorStats(*Executor());
370-
statsBuilder.FillTxCompleteLag(GetTxCompleteLag());
371365
if (TablesManager.HasPrimaryIndex()) {
372366
auto columnEngineStats = TablesManager.GetPrimaryIndexSafe().GetStats().FindPtr(pathId);
373367
if (columnEngineStats && *columnEngineStats) {

ydb/core/tx/columnshard/columnshard_private_events.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,13 +141,13 @@ struct TEvPrivate {
141141
};
142142

143143
struct TEvReadFinished : public TEventLocal<TEvReadFinished, EvReadFinished> {
144-
explicit TEvReadFinished(ui64 requestCookie, ui64 txId, bool success)
145-
: RequestCookie(requestCookie), TxId(txId), Success(success)
146-
{}
144+
explicit TEvReadFinished(ui64 requestCookie, ui64 txId)
145+
: RequestCookie(requestCookie)
146+
, TxId(txId) {
147+
}
147148

148149
ui64 RequestCookie;
149150
ui64 TxId;
150-
bool Success;
151151
};
152152

153153
struct TEvPeriodicWakeup : public TEventLocal<TEvPeriodicWakeup, EvPeriodicWakeup> {

ydb/core/tx/columnshard/counters/aggregation/table_stats.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ void TTableStatsBuilder::FillBackgroundControllerStats(const TBackgroundControll
2222
stats.FillTotalStats(TableStats);
2323
}
2424

25+
void TTableStatsBuilder::FillScanCountersStats(const TScanCounters& stats) {
26+
stats.FillStats(TableStats);
27+
}
28+
2529
void TTableStatsBuilder::FillExecutorStats(const NTabletFlatExecutor::NFlatExecutorSetup::IExecutor& executor) {
2630
TableStats.SetInFlightTxCount(executor.GetStats().TxInFly);
2731
TableStats.SetHasLoanedParts(executor.HasLoanedParts());
2832
}
2933

30-
void TTableStatsBuilder::FillTxCompleteLag(TDuration txCompleteLag) {
31-
TableStats.SetTxCompleteLagMsec(txCompleteLag.MilliSeconds());
32-
}
33-
3434
void TTableStatsBuilder::FillColumnEngineStats(const NOlap::TColumnEngineStats& stats) {
3535
auto activeStats = stats.Active(); // data stats excluding inactive and evicted
3636
TableStats.SetRowCount(activeStats.Rows);

ydb/core/tx/columnshard/counters/aggregation/table_stats.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#pragma once
22

3+
#include <ydb/core/tx/columnshard/counters/scan.h>
34
#include <ydb/core/tablet_flat/tablet_flat_executor.h>
45
#include <ydb/core/tx/columnshard/counters/column_tables.h>
56
#include <ydb/core/tx/columnshard/counters/tablet_counters.h>
@@ -26,9 +27,9 @@ class TTableStatsBuilder {
2627
void FillBackgroundControllerStats(const TBackgroundControllerCounters& stats, ui64 pathId);
2728
void FillBackgroundControllerStats(const TBackgroundControllerCounters& stats);
2829

29-
void FillExecutorStats(const NTabletFlatExecutor::NFlatExecutorSetup::IExecutor& executor);
30+
void FillScanCountersStats(const TScanCounters& stats);
3031

31-
void FillTxCompleteLag(TDuration txCompleteLag);
32+
void FillExecutorStats(const NTabletFlatExecutor::NFlatExecutorSetup::IExecutor& executor);
3233

3334
void FillColumnEngineStats(const NOlap::TColumnEngineStats& stats);
3435
};

ydb/core/tx/columnshard/counters/scan.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,14 @@ TScanCounters::TScanCounters(const TString& module)
8888
ScanIntervalState = std::make_shared<TScanIntervalState>(*this);
8989
ResourcesSubscriberCounters = std::make_shared<NOlap::NResourceBroker::NSubscribe::TSubscriberCounters>();
9090
ScanDurationByStatus.resize((ui32)EStatusFinish::COUNT);
91+
ScansFinishedByStatus.resize((ui32)EStatusFinish::COUNT);
9192
ui32 idx = 0;
9293
for (auto&& i : GetEnumAllValues<EStatusFinish>()) {
9394
if (i == EStatusFinish::COUNT) {
9495
continue;
9596
}
9697
ScanDurationByStatus[(ui32)i] = TBase::GetHistogram("ScanDuration/" + ::ToString(i) + "/Milliseconds", NMonitoring::ExponentialHistogram(18, 2, 1));
98+
ScansFinishedByStatus[(ui32)i] = TBase::GetDeriviative("ScansFinised/" + ::ToString(i));
9799
AFL_VERIFY(idx == (ui32)i);
98100
++idx;
99101
}
@@ -103,4 +105,8 @@ NKikimr::NColumnShard::TScanAggregations TScanCounters::BuildAggregations() {
103105
return TScanAggregations(GetModuleId());
104106
}
105107

108+
void TScanCounters::FillStats(::NKikimrTableStats::TTableStats& output) const {
109+
output.SetRangeReads(ScansFinishedByStatus[(ui32)EStatusFinish::Success]->Val());
110+
}
111+
106112
}

ydb/core/tx/columnshard/counters/scan.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#pragma once
22
#include "common/owner.h"
33
#include "common/histogram.h"
4+
#include <ydb/core/protos/table_stats.pb.h>
45
#include <ydb/core/tx/columnshard/resources/memory.h>
56
#include <ydb/core/tx/columnshard/resource_subscriber/counters.h>
67
#include <ydb/core/tx/columnshard/resource_subscriber/task.h>
@@ -127,6 +128,7 @@ class TScanCounters: public TCommonCountersOwner {
127128
NMonitoring::TDynamicCounters::TCounterPtr AckWaitingDuration;
128129

129130
std::vector<NMonitoring::THistogramPtr> ScanDurationByStatus;
131+
std::vector<NMonitoring::TDynamicCounters::TCounterPtr> ScansFinishedByStatus;
130132

131133
NMonitoring::TDynamicCounters::TCounterPtr NoScanRecords;
132134
NMonitoring::TDynamicCounters::TCounterPtr NoScanIntervals;
@@ -212,9 +214,10 @@ class TScanCounters: public TCommonCountersOwner {
212214
LogScanIntervals->Add(1);
213215
}
214216

215-
void OnScanDuration(const EStatusFinish status, const TDuration d) const {
217+
void OnScanFinished(const EStatusFinish status, const TDuration d) const {
216218
AFL_VERIFY((ui32)status < ScanDurationByStatus.size());
217219
ScanDurationByStatus[(ui32)status]->Collect(d.MilliSeconds());
220+
ScansFinishedByStatus[(ui32)status]->Add(1);
218221
}
219222

220223
void AckWaitingInfo(const TDuration d) const {
@@ -257,6 +260,8 @@ class TScanCounters: public TCommonCountersOwner {
257260
}
258261

259262
TScanAggregations BuildAggregations();
263+
264+
void FillStats(::NKikimrTableStats::TTableStats& output) const;
260265
};
261266

262267
class TCounterGuard: TNonCopyable {

ydb/core/tx/columnshard/counters/tablet_counters.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,13 @@ class TTabletCountersHandle {
7272
output.SetRowUpdates(GetValue(COUNTER_WRITE_SUCCESS));
7373
output.SetRowDeletes(0); // manual deletes are not supported
7474
output.SetRowReads(0); // all reads are range reads
75-
output.SetRangeReads(GetValue(COUNTER_READ_SUCCESS));
7675
output.SetRangeReadRows(GetValue(COUNTER_READ_INDEX_ROWS));
7776

7877
output.SetImmediateTxCompleted(GetValue(COUNTER_IMMEDIATE_TX_COMPLETED));
7978
output.SetTxRejectedByOverload(GetValue(COUNTER_WRITE_OVERLOAD));
8079
output.SetTxRejectedBySpace(GetValue(COUNTER_OUT_OF_SPACE));
8180
output.SetPlannedTxCompleted(GetValue(COUNTER_PLANNED_TX_COMPLETED));
81+
output.SetTxCompleteLagMsec(GetValue(COUNTER_TX_COMPLETE_LAG));
8282
}
8383
};
8484

ydb/core/tx/columnshard/engines/reader/actor/actor.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -400,10 +400,9 @@ void TColumnShardScan::Finish(const NColumnShard::TScanCounters::EStatusFinish s
400400
LOG_DEBUG_S(*TlsActivationContext, NKikimrServices::TX_COLUMNSHARD_SCAN,
401401
"Scan " << ScanActorId << " finished for tablet " << TabletId);
402402

403-
bool success = (status == NColumnShard::TScanCounters::EStatusFinish::Success);
404-
Send(ColumnShardActorId, new NColumnShard::TEvPrivate::TEvReadFinished(RequestCookie, TxId, success));
403+
Send(ColumnShardActorId, new NColumnShard::TEvPrivate::TEvReadFinished(RequestCookie, TxId));
405404
AFL_VERIFY(StartInstant);
406-
ScanCountersPool.OnScanDuration(status, TMonotonic::Now() - *StartInstant);
405+
ScanCountersPool.OnScanFinished(status, TMonotonic::Now() - *StartInstant);
407406
ReportStats();
408407
PassAway();
409408
}

ydb/core/tx/columnshard/engines/reader/transaction/tx_scan.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ void TTxScan::Complete(const TActorContext& ctx) {
226226
auto issue = NYql::YqlIssue({}, NYql::TIssuesIds::KIKIMR_TEMPORARILY_UNAVAILABLE, TStringBuilder()
227227
<< "Table " << table << " (shard " << Self->TabletID() << ") scan failed, reason: " << requestCookie.GetErrorMessage());
228228
NYql::IssueToMessage(issue, ev->Record.MutableIssues()->Add());
229-
Self->Stats.GetScanCounters().OnScanDuration(NColumnShard::TScanCounters::EStatusFinish::CannotAddInFlight, TDuration::Zero());
229+
Self->Stats.GetScanCounters().OnScanFinished(NColumnShard::TScanCounters::EStatusFinish::CannotAddInFlight, TDuration::Zero());
230230
ctx.Send(scanComputeActor, ev.Release());
231231
return;
232232
}

0 commit comments

Comments
 (0)