Skip to content

Commit ccadd07

Browse files
jameseh96daverigby
authored andcommitted
MB-47462: Expose CheckpointDestroyerTask mem usage metric
This metric allows monitoring of the memory used by checkpoints which have been detached from their manager. These checkpoints are still accounted for by EPStats `estimatedCheckpointMemUsage`, but it is useful to directly identify this memory usage. Change-Id: I43011fe6ea2f7e8d66f04fc56ff372f5d1f6d139 Reviewed-on: http://review.couchbase.org/c/kv_engine/+/163354 Tested-by: Build Bot <[email protected]> Reviewed-by: Dave Rigby <[email protected]>
1 parent 27402a4 commit ccadd07

File tree

6 files changed

+35
-18
lines changed

6 files changed

+35
-18
lines changed

engines/ep/docs/stats.org

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -403,24 +403,26 @@ The following ratios are encoded as 4-digit integers, e.g.:
403403

404404
** vBucket total stats
405405

406-
| Stat | Description |
407-
|-----------------------------------+------------------------------------------------|
408-
| ep_vb_total | Total vBuckets (count) |
409-
| curr_items_tot | Total number of items |
410-
| curr_items | Number of active items in memory |
411-
| curr_temp_items | Number of temporary items in memory |
412-
| vb_dead_num | Number of dead vBuckets |
413-
| ep_diskqueue_items | Total items in disk queue |
414-
| ep_diskqueue_memory | Total memory used in disk queue |
415-
| ep_diskqueue_fill | Total enqueued items on disk queue |
416-
| ep_diskqueue_drain | Total drained items on disk queue |
417-
| ep_diskqueue_pending | Total bytes of pending writes |
418-
| ep_persist_vbstate_total | Total VB persist state to disk |
419-
| ep_meta_data_memory | Total memory used by meta data |
420-
| ep_meta_data_disk | Total disk used by meta data |
421-
| ep_checkpoint_memory | Memory of items in all checkpoints |
422-
| ep_checkpoint_memory_unreferenced | Memory of items in unref checkpoints |
423-
| ep_checkpoint_memory_overhead | Memory of all checkpoints structures |
406+
| Stat | Description |
407+
|------------------------------------------+------------------------------------------------|
408+
| ep_vb_total | Total vBuckets (count) |
409+
| curr_items_tot | Total number of items |
410+
| curr_items | Number of active items in memory |
411+
| curr_temp_items | Number of temporary items in memory |
412+
| vb_dead_num | Number of dead vBuckets |
413+
| ep_diskqueue_items | Total items in disk queue |
414+
| ep_diskqueue_memory | Total memory used in disk queue |
415+
| ep_diskqueue_fill | Total enqueued items on disk queue |
416+
| ep_diskqueue_drain | Total drained items on disk queue |
417+
| ep_diskqueue_pending | Total bytes of pending writes |
418+
| ep_persist_vbstate_total | Total VB persist state to disk |
419+
| ep_meta_data_memory | Total memory used by meta data |
420+
| ep_meta_data_disk | Total disk used by meta data |
421+
| ep_checkpoint_memory | Memory of items in all checkpoints |
422+
| ep_checkpoint_memory_unreferenced | Memory of items in unref checkpoints |
423+
| ep_checkpoint_memory_overhead | Memory of all checkpoints structures |
424+
| ep_checkpoint_memory_pending_destruction | Memory of checkpoint structures awaiting |
425+
| | destruction by a background task |
424426

425427
*** Active vBucket class stats
426428

engines/ep/src/ep_engine.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3107,6 +3107,9 @@ cb::engine_errc EventuallyPersistentEngine::doEngineStatsLowCardinality(
31073107
kvBucket->getAggregatedVBucketStats(collector,
31083108
cb::prometheus::Cardinality::Low);
31093109

3110+
collector.addStat(Key::ep_checkpoint_memory_pending_destruction,
3111+
kvBucket->getCheckpointPendingDestructionMemoryUsage());
3112+
31103113
kvBucket->getFileStats(collector);
31113114

31123115
collector.addStat(Key::ep_persist_vbstate_total,

engines/ep/src/kv_bucket.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2958,3 +2958,11 @@ CheckpointDestroyerTask& KVBucket::getCkptDestroyerTask(Vbid vbid) const {
29582958
Expects(!ckptDestroyerTasks.empty());
29592959
return *ckptDestroyerTasks[vbid.get() % ckptDestroyerTasks.size()];
29602960
}
2961+
2962+
size_t KVBucket::getCheckpointPendingDestructionMemoryUsage() const {
2963+
size_t memoryUsage = 0;
2964+
for (const auto& task : ckptDestroyerTasks) {
2965+
memoryUsage += task->getMemoryUsage();
2966+
}
2967+
return memoryUsage;
2968+
}

engines/ep/src/kv_bucket.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -878,6 +878,8 @@ class KVBucket : public KVBucketIface {
878878
return chkRemovers.size();
879879
}
880880

881+
size_t getCheckpointPendingDestructionMemoryUsage() const;
882+
881883
protected:
882884
/**
883885
* Get the checkpoint destroyer task responsible for checkpoints from the

engines/ep/tests/ep_testsuite.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7164,6 +7164,7 @@ static enum test_result test_mb19687_fixed(EngineIface* h) {
71647164
"ep_chk_persistence_remains",
71657165
"ep_chk_remover_stime",
71667166
"ep_checkpoint_destruction_tasks",
7167+
"ep_checkpoint_memory_pending_destruction",
71677168
"ep_checkpoint_memory_ratio",
71687169
"ep_checkpoint_memory_recovery_upper_mark",
71697170
"ep_checkpoint_memory_recovery_lower_mark",

include/statistics/stats.def.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,7 @@ STAT(ep_meta_data_disk, , bytes, , )
584584
STAT(ep_checkpoint_memory, , bytes, , )
585585
STAT(ep_checkpoint_memory_unreferenced, , bytes, , )
586586
STAT(ep_checkpoint_memory_overhead, , bytes, , )
587+
STAT(ep_checkpoint_memory_pending_destruction, , bytes, , )
587588
STAT(ep_total_cache_size, , bytes, , )
588589
STAT(rollback_item_count, , count, , )
589590
STAT(ep_num_non_resident, , count, , )

0 commit comments

Comments
 (0)