forked from membase/ep-engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstats.hh
More file actions
471 lines (405 loc) · 15.4 KB
/
stats.hh
File metadata and controls
471 lines (405 loc) · 15.4 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
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
/* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
#ifndef STATS_HH
#define STATS_HH 1
#include <map>
#include <memcached/engine.h>
#include "common.hh"
#include "atomic.hh"
#include "histo.hh"
#include "memory_tracker.hh"
#ifndef DEFAULT_MAX_DATA_SIZE
/* Something something something ought to be enough for anybody */
#define DEFAULT_MAX_DATA_SIZE (std::numeric_limits<size_t>::max())
#endif
static const hrtime_t ONE_SECOND(1000000);
/**
* Global engine stats container.
*/
class EPStats {
public:
EPStats() : dirtyAgeHisto(GrowingWidthGenerator<hrtime_t>(0, ONE_SECOND, 1.4), 25),
dataAgeHisto(GrowingWidthGenerator<hrtime_t>(0, ONE_SECOND, 1.4), 25),
diskCommitHisto(GrowingWidthGenerator<hrtime_t>(0, ONE_SECOND, 1.4), 25),
mlogCompactorHisto(GrowingWidthGenerator<hrtime_t>(0, ONE_SECOND, 1.4), 25),
timingLog(NULL), maxDataSize(DEFAULT_MAX_DATA_SIZE) {}
~EPStats() {
delete timingLog;
}
size_t getMaxDataSize() {
return maxDataSize.get();
}
void setMaxDataSize(size_t size) {
if (size > 0) {
maxDataSize.set(size);
}
}
size_t getTotalMemoryUsed() {
if (memoryTrackerEnabled.get()) {
return totalMemory.get();
}
return currentSize.get() + memOverhead.get();
}
//! Whether we're warming up.
Atomic<bool> warmupComplete;
//! Number of keys warmed up during key-only loading.
Atomic<size_t> warmedUpKeys;
//! Number of key-values warmed up during data loading.
Atomic<size_t> warmedUpValues;
//! Number of warmup failures due to duplicates
Atomic<size_t> warmDups;
//! Number of OOM failures at warmup time.
Atomic<size_t> warmOOM;
//! Fill % of memory used during warmup we're going to enable traffic
Atomic<double> warmupMemUsedCap;
//! Fill % of number of items read during warmup we're going to
// enable traffic
Atomic<double> warmupNumReadCap;
//! The tap throttle write queue cap
Atomic<ssize_t> tapThrottleWriteQueueCap;
//! size of the input queue
Atomic<size_t> queue_size;
//! Size of the in-process (output) queue.
Atomic<size_t> flusher_todo;
//! Number of transaction commits.
Atomic<size_t> flusherCommits;
// # of completed flushes since engine starts up
Atomic<size_t> numCompletedFlush;
//! Total time spent flushing.
Atomic<size_t> cumulativeFlushTime;
//! Total time spent committing.
Atomic<size_t> cumulativeCommitTime;
//! Objects that were rejected from persistence for being too fresh.
Atomic<size_t> tooYoung;
//! Objects that were forced into persistence for being too old.
Atomic<size_t> tooOld;
//! Number of items persisted.
Atomic<size_t> totalPersisted;
//! Cumulative number of items added to the queue.
Atomic<size_t> totalEnqueued;
//! Number of new items created in the DB.
Atomic<size_t> newItems;
//! Number of items removed from the DB.
Atomic<size_t> delItems;
//! Number of times an item flush failed.
Atomic<size_t> flushFailed;
//! Number of times an item is not flushed due to the item's expiry
Atomic<size_t> flushExpired;
//! Number of times an object was expired on access.
Atomic<size_t> expired_access;
//! Number of times an object was expired by pager.
Atomic<size_t> expired_pager;
//! Number of times we failed to start a transaction
Atomic<size_t> beginFailed;
//! Number of times a commit failed.
Atomic<size_t> commitFailed;
//! How long an object is dirty before written.
Atomic<rel_time_t> dirtyAge;
//! Oldest enqueued object we've seen while persisting.
Atomic<rel_time_t> dirtyAgeHighWat;
//! How old persisted data was when it hit the persistence layer
Atomic<rel_time_t> dataAge;
//! Oldest data we've seen while persisting.
Atomic<rel_time_t> dataAgeHighWat;
//! How long does it take to do an entire flush cycle.
Atomic<rel_time_t> flushDuration;
//! Longest flush cycle we've seen.
Atomic<rel_time_t> flushDurationHighWat;
//! Amount of time spent in the commit phase.
Atomic<rel_time_t> commit_time;
//! Number of times we deleted a vbucket.
Atomic<size_t> vbucketDeletions;
//! Number of times we failed to delete a vbucket.
Atomic<size_t> vbucketDeletionFail;
//! Beyond this point are config items
//! Minimum data age before a record can be persisted
Atomic<int> min_data_age;
//! Maximum data age before a record is forced to be persisted
Atomic<int> queue_age_cap;
//! Number of times background fetches occurred.
Atomic<size_t> bg_fetched;
//! Number of times we needed to kick in the pager
Atomic<size_t> pagerRuns;
//! Number of times the expiry pager runs for purging expired items
Atomic<size_t> expiryPagerRuns;
//! Number of times the checkpoint remover runs for removing closed unreferenced checkpoints.
Atomic<size_t> checkpointRemoverRuns;
//! Number of items removed from closed unreferenced checkpoints.
Atomic<size_t> itemsRemovedFromCheckpoints;
//! Number of times a value is ejected
Atomic<size_t> numValueEjects;
//! Number of times a value could not be ejected
Atomic<size_t> numFailedEjects;
//! Number of times "Not my bucket" happened
Atomic<size_t> numNotMyVBuckets;
//! Whether the DB cleaner completes cleaning up invalid items with old vb versions
Atomic<bool> dbCleanerComplete;
//! Number of deleted items reverted from hot reload
Atomic<size_t> numRevertDeletes;
//! Number of new items reverted from hot reload
Atomic<size_t> numRevertAdds;
//! Number of updated items reverted from hot reload
Atomic<size_t> numRevertUpdates;
//! Total size of stored objects.
Atomic<size_t> currentSize;
//! Total memory overhead to store values for resident keys.
Atomic<size_t> totalValueSize;
//! Amount of memory used to track items and what-not.
Atomic<size_t> memOverhead;
//! The total amount of memory used by this bucket (From memory tracking)
Atomic<size_t> totalMemory;
//! True if the memory usage tracker is enabled.
Atomic<bool> memoryTrackerEnabled;
//! Pager low water mark.
Atomic<size_t> mem_low_wat;
//! Pager high water mark
Atomic<size_t> mem_high_wat;
//! Number of times unrecoverable oom errors happened while processing operations.
Atomic<size_t> oom_errors;
//! Number of times temporary oom errors encountered while processing operations.
Atomic<size_t> tmp_oom_errors;
//! Number of read related io operations
Atomic<size_t> io_num_read;
//! Number of write related io operations
Atomic<size_t> io_num_write;
//! Number of bytes read
Atomic<size_t> io_read_bytes;
//! Number of bytes written
Atomic<size_t> io_write_bytes;
//! Number of ops blocked on all vbuckets in pending state
Atomic<size_t> pendingOps;
//! Total number of ops ever blocked on all vbuckets in pending state
Atomic<size_t> pendingOpsTotal;
//! High water value for ops blocked for any individual pending vbucket
Atomic<size_t> pendingOpsMax;
//! High water value for time an op is blocked on a pending vbucket
Atomic<hrtime_t> pendingOpsMaxDuration;
//! Histogram of pending operation wait times.
Histogram<hrtime_t> pendingOpsHisto;
//! The number of samples the bgWaitDelta and bgLoadDelta contains of
Atomic<size_t> bgNumOperations;
/** The sum of the deltas (in usec) from an item was put in queue until
* the dispatcher started the work for this item
*/
Atomic<hrtime_t> bgWait;
//! The shortest wait time
Atomic<hrtime_t> bgMinWait;
//! The longest wait time
Atomic<hrtime_t> bgMaxWait;
//! Histogram of background wait times.
Histogram<hrtime_t> bgWaitHisto;
/** The sum of the deltas (in usec) from the dispatcher started to load
* item until was done
*/
Atomic<hrtime_t> bgLoad;
//! The shortest load time
Atomic<hrtime_t> bgMinLoad;
//! The longest load time
Atomic<hrtime_t> bgMaxLoad;
//! Max wall time of deleting a vbucket
Atomic<hrtime_t> vbucketDelMaxWalltime;
//! Total wall time of deleting vbuckets
Atomic<hrtime_t> vbucketDelTotWalltime;
//! Histogram of background wait loads.
Histogram<hrtime_t> bgLoadHisto;
//! Histogram of time an item spends non-resident.
Histogram<rel_time_t> pagedOutTimeHisto;
/* TAP related stats */
//! The total number of tap events sent (not including noops)
Atomic<size_t> numTapFetched;
//! Number of background fetched tap items
Atomic<size_t> numTapBGFetched;
//! Number of times a tap background fetch task is requeued
Atomic<size_t> numTapBGFetchRequeued;
//! Number of foreground fetched tap items
Atomic<size_t> numTapFGFetched;
//! Number of tap deletes.
Atomic<size_t> numTapDeletes;
//! The number of samples the tapBgWaitDelta and tapBgLoadDelta contains of
Atomic<size_t> tapBgNumOperations;
//! The number of tap notify messages throttled by TapThrottle.
Atomic<size_t> tapThrottled;
//! Percentage of memory in use before we throttle tap input
Atomic<double> tapThrottleThreshold;
/** The sum of the deltas (in usec) from a tap item was put in queue until
* the dispatcher started the work for this item
*/
Atomic<hrtime_t> tapBgWait;
//! The shortest tap bg wait time
Atomic<hrtime_t> tapBgMinWait;
//! The longest tap bg wait time
Atomic<hrtime_t> tapBgMaxWait;
//! Histogram of tap background wait loads.
Histogram<hrtime_t> tapBgWaitHisto;
/** The sum of the deltas (in usec) from the dispatcher started to load
* a tap item until was done
*/
Atomic<hrtime_t> tapBgLoad;
//! The shortest tap load time
Atomic<hrtime_t> tapBgMinLoad;
//! The longest tap load time
Atomic<hrtime_t> tapBgMaxLoad;
//! The number of get with meta operations
Atomic<size_t> numOpsGetMeta;
//! The number of set with meta operations
Atomic<size_t> numOpsSetMeta;
//! The number of delete with meta operations
Atomic<size_t> numOpsDelMeta;
//! The number of tiems the mutation log compactor is exectued
Atomic<size_t> mlogCompactorRuns;
//! The number of tiems the access scanner runs
Atomic<size_t> alogRuns;
//! The next access scanner task schedule time (GMT)
Atomic<hrtime_t> alogTime;
//! Histogram of tap background wait loads.
Histogram<hrtime_t> tapBgLoadHisto;
//! Histogram of queue processing dirty age.
Histogram<hrtime_t> dirtyAgeHisto;
//! Histogram of queue processing data age.
Histogram<hrtime_t> dataAgeHisto;
//! Histogram of item allocation sizes.
Histogram<size_t> itemAllocSizeHisto;
//
// Command timers
//
//! Histogram of getvbucket timings
Histogram<hrtime_t> getVbucketCmdHisto;
//! Histogram of setvbucket timings
Histogram<hrtime_t> setVbucketCmdHisto;
//! Histogram of delvbucket timings
Histogram<hrtime_t> delVbucketCmdHisto;
//! Histogram of get commands.
Histogram<hrtime_t> getCmdHisto;
//! Histogram of arithmetic commands.
Histogram<hrtime_t> arithCmdHisto;
//! Histogram of tap VBucket reset timings
Histogram<hrtime_t> tapVbucketResetHisto;
//! Histogram of tap mutation timings.
Histogram<hrtime_t> tapMutationHisto;
//! Histogram of tap vbucket set timings.
Histogram<hrtime_t> tapVbucketSetHisto;
//! Time spent notifying completion of IO.
Histogram<hrtime_t> notifyIOHisto;
//! Histogram of get_stats commands.
Histogram<hrtime_t> getStatsCmdHisto;
//
// DB timers.
//
//! Histogram of insert disk writes
Histogram<hrtime_t> diskInsertHisto;
//! Histogram of update disk writes
Histogram<hrtime_t> diskUpdateHisto;
//! Histogram of delete disk writes
Histogram<hrtime_t> diskDelHisto;
//! Histogram of execution time of disk vbucket deletions
Histogram<hrtime_t> diskVBDelHisto;
//! Histogram of execution time of invalid vbucket table deletions from disk
Histogram<hrtime_t> diskInvalidVBTableDelHisto;
//! Histogram of disk commits
Histogram<hrtime_t> diskCommitHisto;
Histogram<hrtime_t> checkpointRevertHisto;
//! Histogram of setting vbucket state
Histogram<hrtime_t> snapshotVbucketHisto;
//! Histogram of mutation log compactor
Histogram<hrtime_t> mlogCompactorHisto;
//! Historgram of batch reads
Histogram<hrtime_t> getMultiHisto;
//! Reset all stats to reasonable values.
void reset() {
tooYoung.set(0);
tooOld.set(0);
dirtyAge.set(0);
dirtyAgeHighWat.set(0);
flushDuration.set(0);
flushDurationHighWat.set(0);
commit_time.set(0);
pagerRuns.set(0);
checkpointRemoverRuns.set(0);
itemsRemovedFromCheckpoints.set(0);
numValueEjects.set(0);
numFailedEjects.set(0);
numNotMyVBuckets.set(0);
io_num_read.set(0);
io_num_write.set(0);
io_read_bytes.set(0);
io_write_bytes.set(0);
bgNumOperations.set(0);
bgWait.set(0);
bgLoad.set(0);
bgMinWait.set(999999999);
bgMaxWait.set(0);
bgMinLoad.set(999999999);
bgMaxLoad.set(0);
tapBgNumOperations.set(0);
tapBgWait.set(0);
tapBgLoad.set(0);
tapBgMinWait.set(999999999);
tapBgMaxWait.set(0);
tapBgMinLoad.set(999999999);
tapBgMaxLoad.set(0);
tapThrottled.set(0);
pendingOps.set(0);
pendingOpsTotal.set(0);
pendingOpsMax.set(0);
pendingOpsMaxDuration.set(0);
numTapFetched.set(0);
vbucketDelMaxWalltime.set(0);
vbucketDelTotWalltime.set(0);
mlogCompactorRuns.set(0);
alogRuns.set(0);
pendingOpsHisto.reset();
bgWaitHisto.reset();
bgLoadHisto.reset();
pagedOutTimeHisto.reset();
tapBgWaitHisto.reset();
tapBgLoadHisto.reset();
getVbucketCmdHisto.reset();
setVbucketCmdHisto.reset();
delVbucketCmdHisto.reset();
getCmdHisto.reset();
arithCmdHisto.reset();
tapVbucketResetHisto.reset();
tapMutationHisto.reset();
tapVbucketSetHisto.reset();
notifyIOHisto.reset();
getStatsCmdHisto.reset();
diskInsertHisto.reset();
diskUpdateHisto.reset();
diskDelHisto.reset();
diskVBDelHisto.reset();
diskInvalidVBTableDelHisto.reset();
diskCommitHisto.reset();
dataAgeHisto.reset();
itemAllocSizeHisto.reset();
dirtyAgeHisto.reset();
mlogCompactorHisto.reset();
getMultiHisto.reset();
}
// Used by stats logging infrastructure.
std::ostream *timingLog;
private:
//! Max allowable memory size.
Atomic<size_t> maxDataSize;
DISALLOW_COPY_AND_ASSIGN(EPStats);
};
/**
* Stats returned by key stats.
*/
struct key_stats {
//! The item's CAS
uint64_t cas;
//! The expiration time of the itme
rel_time_t exptime;
//! When the item was dirtied (if applicable).
rel_time_t data_age;
//! Last modification time
rel_time_t last_modification_time;
//! The item's current flags.
uint32_t flags;
//! The vbucket state for this key
vbucket_state_t vb_state;
//! True if this item is dirty.
bool dirty;
//! True if the item has been logically deleted
bool logically_deleted;
};
#endif /* STATS_HH */