-
Notifications
You must be signed in to change notification settings - Fork 46
Expand file tree
/
Copy pathtablet_counters.h
More file actions
360 lines (291 loc) · 15.3 KB
/
Copy pathtablet_counters.h
File metadata and controls
360 lines (291 loc) · 15.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
#pragma once
#include "public.h"
#include "tablet_tx.h"
#include <cloud/filestore/libs/diagnostics/metrics/histogram.h>
#include <cloud/filestore/libs/diagnostics/metrics/key.h>
#include <cloud/filestore/libs/diagnostics/metrics/public.h>
#include <cloud/filestore/libs/diagnostics/metrics/window_calculator.h>
#include <cloud/filestore/libs/storage/api/tablet.h>
#include <cloud/filestore/libs/storage/core/tablet_counters.h>
#include <cloud/filestore/libs/storage/model/block_buffer.h>
#include <cloud/filestore/libs/storage/tablet/model/request_metrics.h>
#include <cloud/storage/core/libs/diagnostics/busy_idle_calculator.h>
#include <contrib/ydb/core/tablet/tablet_counters_protobuf.h>
namespace NCloud::NFileStore::NStorage {
////////////////////////////////////////////////////////////////////////////////
#define FILESTORE_TABLET_STATS(xxx, ...) \
xxx(UsedNodesCount, __VA_ARGS__) \
xxx(UsedSessionsCount, __VA_ARGS__) \
xxx(UsedHandlesCount, __VA_ARGS__) \
xxx(UsedLocksCount, __VA_ARGS__) \
xxx(UsedBlocksCount, __VA_ARGS__) \
\
xxx(FreshBlocksCount, __VA_ARGS__) \
xxx(MixedBlocksCount, __VA_ARGS__) \
xxx(MixedBlobsCount, __VA_ARGS__) \
xxx(DeletionMarkersCount, __VA_ARGS__) \
xxx(GarbageQueueSize, __VA_ARGS__) \
xxx(GarbageBlocksCount, __VA_ARGS__) \
xxx(CheckpointNodesCount, __VA_ARGS__) \
xxx(CheckpointBlocksCount, __VA_ARGS__) \
xxx(CheckpointBlobsCount, __VA_ARGS__) \
xxx(FreshBytesCount, __VA_ARGS__) \
xxx(DeletedFreshBytesCount, __VA_ARGS__) \
xxx(LastCollectCommitId, __VA_ARGS__) \
xxx(LargeDeletionMarkersCount, __VA_ARGS__) \
// FILESTORE_TABLET_STATS
////////////////////////////////////////////////////////////////////////////////
struct TIndexTabletCounters
{
enum ETransactionType
{
#define FILESTORE_TRANSACTION_TYPE(name, ...) TX_##name,
FILESTORE_TABLET_TRANSACTIONS(FILESTORE_TRANSACTION_TYPE)
TX_SIZE
#undef FILESTORE_TRANSACTION_TYPE
};
static const char* const TransactionTypeNames[TX_SIZE];
};
////////////////////////////////////////////////////////////////////////////////
using TTabletCountersPtr = std::unique_ptr<NKikimr::TTabletCountersWithTxTypes>;
TTabletCountersPtr CreateIndexTabletCounters();
////////////////////////////////////////////////////////////////////////////////
#define FILESTORE_TABLET_METRICS_REQUESTS_INTERNAL(xxx, ...) \
xxx(ReadBlob, __VA_ARGS__) \
xxx(WriteBlob, __VA_ARGS__) \
xxx(PatchBlob, __VA_ARGS__) \
// FILESTORE_TABLET_METRICS_REQUESTS_INTERNAL
#define FILESTORE_TABLET_METRICS_REQUESTS_PRIVATE(xxx, ...) \
xxx(DescribeData, __VA_ARGS__) \
xxx(GenerateBlobIds, __VA_ARGS__) \
xxx(AddData, __VA_ARGS__) \
xxx(AddDataUnconfirmed, __VA_ARGS__) \
xxx(ConfirmAddData, __VA_ARGS__) \
xxx(CancelAddData, __VA_ARGS__) \
xxx(GetStorageStats, __VA_ARGS__) \
xxx(GetNodeAttrBatch, __VA_ARGS__) \
xxx(RenameNodeInDestination, __VA_ARGS__) \
xxx(PrepareUnlinkDirectoryNodeInShard, __VA_ARGS__) \
xxx(AbortUnlinkDirectoryNodeInShard, __VA_ARGS__) \
// FILESTORE_TABLET_METRICS_REQUESTS_PRIVATE
#define FILESTORE_TABLET_METRICS_REQUESTS_PUBLIC(xxx, ...) \
xxx(ReadData, __VA_ARGS__) \
xxx(WriteData, __VA_ARGS__) \
xxx(ListNodes, __VA_ARGS__) \
xxx(GetNodeAttr, __VA_ARGS__) \
xxx(GetNodeAttrInShard, __VA_ARGS__) \
xxx(CreateHandle, __VA_ARGS__) \
xxx(CreateHandleInShard, __VA_ARGS__) \
xxx(ConfirmCreateHandle, __VA_ARGS__) \
xxx(DestroyHandle, __VA_ARGS__) \
xxx(CreateNode, __VA_ARGS__) \
xxx(CreateNodeInShard, __VA_ARGS__) \
xxx(RenameNode, __VA_ARGS__) \
xxx(UnlinkNode, __VA_ARGS__) \
xxx(UnlinkNodeInShard, __VA_ARGS__) \
xxx(StatFileStore, __VA_ARGS__) \
xxx(GetNodeXAttr, __VA_ARGS__) \
// FILESTORE_TABLET_METRICS_REQUESTS_PUBLIC
#define FILESTORE_TABLET_METRICS_REQUESTS_BACKGROUND(xxx, ...) \
xxx(Compaction, __VA_ARGS__) \
xxx(Cleanup, __VA_ARGS__) \
xxx(Flush, __VA_ARGS__) \
xxx(FlushBytes, __VA_ARGS__) \
xxx(TrimBytes, __VA_ARGS__) \
xxx(CollectGarbage, __VA_ARGS__) \
// FILESTORE_TABLET_METRICS_REQUESTS_BACKGROUND
#define FILESTORE_TABLET_METRICS_REQUESTS(xxx, ...) \
FILESTORE_TABLET_METRICS_REQUESTS_INTERNAL(xxx, __VA_ARGS) \
FILESTORE_TABLET_METRICS_REQUESTS_PRIVATE(xxx, __VA_ARGS) \
FILESTORE_TABLET_METRICS_REQUESTS_PUBLIC(xxx, __VA_ARGS) \
FILESTORE_TABLET_METRICS_REQUESTS_BACKGROUND(xxx, __VA_ARGS) \
// FILESTORE_TABLET_METRICS_REQUESTS_BACKGROUND
////////////////////////////////////////////////////////////////////////////////
/**
* This data structure holds index tablet actor-level metrics. Tracking new
* requests is thread-safe. Initialization/registration and complex functions
* that iterate various metrics are supposed to be called only by the tablet
* actor and are not thread-safe. So it's ok to pass a smart pointer to this
* structure to some other thread/actor for request completion tracking.
*/
struct TTabletMetrics: TAtomicRefCount<TTabletMetrics>
{
bool Initialized{false};
std::atomic<i64> TotalBytesCount{0};
std::atomic<i64> UsedBytesCount{0};
std::atomic<i64> AggregateUsedBytesCount{0};
std::atomic<i64> TotalNodesCount{0};
std::atomic<i64> UsedNodesCount{0};
std::atomic<i64> AggregateUsedNodesCount{0};
std::atomic<i64> UsedSessionsCount{0};
std::atomic<i64> UsedHandlesCount{0};
std::atomic<i64> UsedDirectHandlesCount{0};
std::atomic<i64> SevenBytesHandlesCount{0};
std::atomic<i64> UsedLocksCount{0};
std::atomic<i64> NodeExistsWhileCreatingInShardCount{0};
std::atomic<i64> CreateNodeInShardRetryCount{0};
std::atomic<i64> ReplayedCreateNodeInShardRequestsCount{0};
std::atomic<i64> StrictFileSystemSizeEnforcementEnabled{0};
std::atomic<i64> DirectoryCreationInShardsEnabled{0};
// Session stats
std::atomic<i64> StatefulSessionsCount{0};
std::atomic<i64> StatelessSessionsCount{0};
std::atomic<i64> ActiveSessionsCount{0};
std::atomic<i64> OrphanSessionsCount{0};
std::atomic<i64> SessionTimeouts{0};
std::atomic<i64> SessionCleanupAttempts{0};
std::atomic<i64> AllocatedCompactionRangesCount{0};
std::atomic<i64> UsedCompactionRangesCount{0};
std::atomic<i64> ReassignCount{0};
std::atomic<i64> WritableChannelCount{0};
std::atomic<i64> UnwritableChannelCount{0};
std::atomic<i64> ChannelsToMoveCount{0};
std::atomic<i64> ReadAheadCacheHitCount{0};
std::atomic<i64> ReadAheadCacheNodeCount{0};
std::atomic<i64> ReadNodeCacheBypassCount{0};
std::atomic<i64> ReadAheadCacheBypassCount{0};
// Read-only transactions that used fast path (in-memory index state)
std::atomic<i64> InMemoryIndexStateROCacheHitCount{0};
// Read-only transactions that used slow path
std::atomic<i64> InMemoryIndexStateROCacheMissCount{0};
// Read-write transactions
std::atomic<i64> InMemoryIndexStateRWCount{0};
std::atomic<i64> InMemoryIndexStateNodesCount;
std::atomic<i64> InMemoryIndexStateNodesCapacity;
std::atomic<i64> InMemoryIndexStateNodeRefsCount;
std::atomic<i64> InMemoryIndexStateNodeRefsCapacity;
std::atomic<i64> InMemoryIndexStateNodeAttrsCount;
std::atomic<i64> InMemoryIndexStateNodeAttrsCapacity;
std::atomic<i64> InMemoryIndexStateNodeRefsExhaustivenessCount;
std::atomic<i64> InMemoryIndexStateNodeRefsExhaustivenessCapacity;
std::atomic<i64> InMemoryIndexStateIsExhaustive;
// Mixed index in-memory stats
std::atomic<i64> MixedIndexLoadedRanges{0};
std::atomic<i64> MixedIndexOffloadedRanges{0};
// Data stats
std::atomic<i64> FreshBytesCount{0};
std::atomic<i64> FreshBytesItemCount{0};
std::atomic<i64> DeletedFreshBytesCount{0};
std::atomic<i64> MixedBytesCount{0};
std::atomic<i64> MixedBlobsCount{0};
std::atomic<i64> DeletionMarkersCount{0};
std::atomic<i64> LargeDeletionMarkersCount{0};
std::atomic<i64> GarbageQueueSize{0};
std::atomic<i64> GarbageBytesCount{0};
std::atomic<i64> FreshBlocksCount{0};
std::atomic<i64> CMMixedBlobsCount{0};
std::atomic<i64> CMDeletionMarkersCount{0};
std::atomic<i64> CMGarbageBlocksCount{0};
std::atomic<i64> CollectCommitId{0};
// Backpressure Write throttling
std::atomic<i64> IsWriteAllowed{0};
std::atomic<i64> FlushBackpressureValue{0};
std::atomic<i64> FlushBackpressureThreshold{0};
std::atomic<i64> FlushBytesBackpressureValue{0};
std::atomic<i64> FlushBytesBackpressureThreshold{0};
std::atomic<i64> FlushBytesItemCountBackpressureValue{0};
std::atomic<i64> FlushBytesItemCountBackpressureThreshold{0};
std::atomic<i64> CompactionBackpressureValue{0};
std::atomic<i64> CompactionBackpressureThreshold{0};
std::atomic<i64> CleanupBackpressureValue{0};
std::atomic<i64> CleanupBackpressureThreshold{0};
std::atomic<i64> CollectGarbageBackpressureValue{0};
std::atomic<i64> CollectGarbageBackpressureThreshold{0};
// Throttling
std::atomic<i64> MaxReadBandwidth{0};
std::atomic<i64> MaxWriteBandwidth{0};
std::atomic<i64> MaxReadIops{0};
std::atomic<i64> MaxWriteIops{0};
std::atomic<i64> RejectedRequests{0};
std::atomic<i64> PostponedRequests{0};
std::atomic<i64> UsedQuota{0};
// Tablet busy/idle time
std::atomic<i64> BusyTime{0};
std::atomic<i64> IdleTime{0};
TBusyIdleTimeCalculatorAtomics BusyIdleCalc;
// Tablet-specific stats
std::atomic<i64> TabletStartTimestamp{0};
std::atomic<i64> TabletId{0};
std::atomic<i64> TabletGeneration{0};
// Blob compression stats
std::atomic<i64> UncompressedBytesWritten{0};
std::atomic<i64> CompressedBytesWritten{0};
// HandleStatsByNode size stats
std::atomic<i64> HandleStatsByNodeMaxSize{0};
std::atomic<i64> HandleStatsByNodeSumSize{0};
std::atomic<i64> HandleStatsByNodeMaxTotalSize{0};
std::atomic<i64> HandleStatsByNodeSumTotalSize{0};
// Opened nodes stats
std::atomic<i64> NodesOpenForWritingBySingleSession{0};
std::atomic<i64> NodesOpenForWritingByMultipleSessions{0};
std::atomic<i64> NodesOpenForReadingBySingleSession{0};
std::atomic<i64> NodesOpenForReadingByMultipleSessions{0};
std::atomic<i64> OrphanNodesCount{0};
NMetrics::TDefaultWindowCalculator MaxUsedQuota{0};
using TLatHistogram =
NMetrics::THistogram<NMetrics::EHistUnit::HU_TIME_MICROSECONDS>;
TLatHistogram ReadDataPostponed;
TLatHistogram WriteDataPostponed;
#define FILESTORE_TABLET_METRICS_REQUEST(name, ...) \
TTabletRequestMetrics name; \
// FILESTORE_TABLET_METRICS_REQUEST
FILESTORE_TABLET_METRICS_REQUESTS(FILESTORE_TABLET_METRICS_REQUEST)
#undef FILESTORE_TABLET_METRICS_REQUEST
struct TExtraCompactionMetrics
{
std::atomic<i64> DudCount{0};
} CompactionExtra;
struct TExtraListNodesMetrics
{
std::atomic<i64> RequestedBytesPrecharge{0};
std::atomic<i64> PrepareAttempts{0};
std::atomic<i64> ResponseNodeRefs{0};
} ListNodesExtra;
struct TExtraCreateHandleMetrics
{
std::atomic<i64> GuestKeepCacheSet{0};
} CreateHandleExtra;
struct TExtraConfirmAddDataMetrics
{
std::atomic<i64> DeferredCount{0};
} ConfirmAddDataExtra;
i64 LastNetworkMetric = 0;
// Compaction/Cleanup stats
std::atomic<i64> MaxBlobsInRange{0};
std::atomic<i64> MaxDeletionsInRange{0};
std::atomic<i64> MaxGarbageBlocksInRange{0};
// performance evaluation
std::atomic<i64> CurrentLoad{0};
std::atomic<i64> Suffer{0};
std::atomic<i64> OverloadedCount{0};
TInstant PrevCPUUsageMicrosTs;
i64 PrevCPUUsageMicros{0};
std::atomic<i64> CPUUsageMicros{0};
std::atomic<i64> CPUUsageRate{0};
std::atomic<i64> OpLogEntryCount{0};
std::atomic<i64> ResponseLogEntryCount{0};
std::atomic<i64> RenameNotSupportedErrorCount{0};
std::atomic<i64> ShardBalancerUpdateErrorCount{0};
const NMetrics::IMetricsRegistryPtr StorageRegistry;
const NMetrics::IMetricsRegistryPtr StorageFsRegistry;
NMetrics::IMetricsRegistryPtr FsRegistry;
NMetrics::IMetricsRegistryPtr AggregatableFsRegistry;
// Keys of the registrations that hold FsRegistry alive, needed by ~TTabletMetrics().
NMetrics::TMetricKey MaxUsedQuotaKey;
NMetrics::TMetricKey ReadDataPostponedKey;
NMetrics::TMetricKey WriteDataPostponedKey;
explicit TTabletMetrics(NMetrics::IMetricsRegistryPtr metricsRegistry);
~TTabletMetrics();
void Register(
const TString& fsId,
const TString& cloudId,
const TString& folderId,
const TString& mediaKind);
void UpdatePerformanceMetrics(
TInstant now,
const TDiagnosticsConfig& diagConfig,
const NProto::TFileSystem& fileSystem);
i64 CalculateNetworkRequestBytes(ui32 nonNetworkMetricsBalancingFactor);
};
using TTabletMetricsPtr = TIntrusivePtr<TTabletMetrics>;
} // namespace NCloud::NFileStore::NStorage