Skip to content

Commit 43bc8d2

Browse files
owend74daverigby
authored andcommitted
MB-33768: Add stat for num of items expelled from checkpoints
Adds the stat ep_items_expelled_from_checkpoints, which records the total number of items (including meta items) that have been expelled from checkpoints. It copies a similar format to the ep_items_rm_from_checkpoints, which tracks to the total number of items removed from checkpoints. Change-Id: I673d4ef35c3c33b8013342886d8807c91a7f3cff Reviewed-on: http://review.couchbase.org/107713 Reviewed-by: Jim Walker <[email protected]> Tested-by: Build Bot <[email protected]>
1 parent d72f776 commit 43bc8d2

File tree

7 files changed

+21
-0
lines changed

7 files changed

+21
-0
lines changed

engines/ep/docs/stats.org

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,11 @@ For introductory information on stats within Couchbase, start with the
160160
| ep_expiry_pager_task_time | Time of the next expiry pager task |
161161
| | (GMT), NOT_SCHEDULED if expiry pager |
162162
| | has been disabled |
163+
| ep_items_expelled_from_checkpoints | Number of items expelled from |
164+
| | checkpoints. Expelled refers to items |
165+
| | that have been ejected from memory |
166+
| | but are still considered to be part of |
167+
| | the checkpoint. |
163168
| ep_items_rm_from_checkpoints | Number of items removed from closed |
164169
| | unreferenced checkpoints |
165170
| ep_num_value_ejects | Number of times item values got |
@@ -1250,6 +1255,7 @@ Reset Stats:
12501255
| ep_io_num_write |
12511256
| ep_io_bg_fetch_doc_bytes |
12521257
| ep_io_write_bytes |
1258+
| ep_items_expelled_from_checkpoints |
12531259
| ep_items_rm_from_checkpoints |
12541260
| ep_num_eject_failures |
12551261
| ep_num_pager_runs |

engines/ep/src/checkpoint_manager.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,8 @@ size_t CheckpointManager::expelUnreferencedCheckpointItems() {
565565
expelledItems = currentCheckpoint->expelItems(expelUpToAndIncluding);
566566
}
567567

568+
stats.itemsExpelledFromCheckpoints.fetch_add(expelledItems.size());
569+
568570
/*
569571
* We are now outside of the queueLock when the method exits,
570572
* expelledItems will go out of scope and so the reference count

engines/ep/src/ep_engine.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2702,6 +2702,9 @@ ENGINE_ERROR_CODE EventuallyPersistentEngine::doEngineStats(
27022702
epstats.freqDecayerRuns,
27032703
add_stat,
27042704
cookie);
2705+
add_casted_stat("ep_items_expelled_from_checkpoints",
2706+
epstats.itemsExpelledFromCheckpoints,
2707+
add_stat, cookie);
27052708
add_casted_stat("ep_items_rm_from_checkpoints",
27062709
epstats.itemsRemovedFromCheckpoints,
27072710
add_stat, cookie);

engines/ep/src/stats.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ EPStats::EPStats()
6666
pagerRuns(0),
6767
expiryPagerRuns(0),
6868
freqDecayerRuns(0),
69+
itemsExpelledFromCheckpoints(0),
6970
itemsRemovedFromCheckpoints(0),
7071
numValueEjects(0),
7172
numFailedEjects(0),

engines/ep/src/stats.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,8 @@ class EPStats {
230230
Counter expiryPagerRuns;
231231
//! Number of times the item frequency decayer runs
232232
Counter freqDecayerRuns;
233+
//! The number items expelled from checkpoints
234+
Counter itemsExpelledFromCheckpoints;
233235
//! Number of items removed from closed unreferenced checkpoints.
234236
Counter itemsRemovedFromCheckpoints;
235237
//! Number of times a value is ejected
@@ -505,6 +507,7 @@ class EPStats {
505507
pagerRuns.store(0);
506508
expiryPagerRuns.store(0);
507509
freqDecayerRuns.store(0);
510+
itemsExpelledFromCheckpoints.store(0);
508511
itemsRemovedFromCheckpoints.store(0);
509512
numValueEjects.store(0);
510513
numFailedEjects.store(0);

engines/ep/tests/ep_testsuite.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6959,6 +6959,7 @@ static enum test_result test_mb19687_fixed(EngineIface* h) {
69596959
"ep_item_freq_decayer_percent",
69606960
"ep_item_num",
69616961
"ep_item_num_based_new_chk",
6962+
"ep_items_expelled_from_checkpoints",
69626963
"ep_items_rm_from_checkpoints",
69636964
"ep_keep_closed_chks",
69646965
"ep_kv_size",

engines/ep/tests/module_tests/checkpoint_test.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1699,6 +1699,7 @@ TYPED_TEST(CheckpointTest, expelCheckpointItemsTest) {
16991699
*/
17001700

17011701
EXPECT_EQ(itemCount + 1, this->manager->expelUnreferencedCheckpointItems());
1702+
EXPECT_EQ(itemCount + 1, this->global_stats.itemsExpelledFromCheckpoints);
17021703

17031704
/*
17041705
* After expelling checkpoint now looks as follows:
@@ -1760,6 +1761,7 @@ TYPED_TEST(CheckpointTest, expelCheckpointItemsWithDuplicateTest) {
17601761
}
17611762

17621763
ASSERT_EQ(itemCount + 1, this->manager->expelUnreferencedCheckpointItems());
1764+
EXPECT_EQ(itemCount + 1, this->global_stats.itemsExpelledFromCheckpoints);
17631765

17641766
/*
17651767
* After expelling checkpoint now looks as follows:
@@ -1812,6 +1814,7 @@ TYPED_TEST(CheckpointTest, expelCursorPointingToLastItem) {
18121814
*/
18131815

18141816
EXPECT_EQ(itemCount + 1 , this->manager->expelUnreferencedCheckpointItems());
1817+
EXPECT_EQ(itemCount + 1, this->global_stats.itemsExpelledFromCheckpoints);
18151818

18161819
/*
18171820
* After expelling checkpoint now looks as follows:
@@ -1841,6 +1844,7 @@ TYPED_TEST(CheckpointTest, expelCursorPointingToChkptStart) {
18411844
*/
18421845

18431846
EXPECT_EQ(0 , this->manager->expelUnreferencedCheckpointItems());
1847+
EXPECT_EQ(0, this->global_stats.itemsExpelledFromCheckpoints);
18441848
}
18451849

18461850
// Test that if we want to evict items from seqno X, but have a meta-data item
@@ -1889,4 +1893,5 @@ TYPED_TEST(CheckpointTest, dontExpelIfCursorAtMetadataItemWithSameSeqno) {
18891893

18901894
// We should not expel any items due to dcpCursor1
18911895
EXPECT_EQ(0, this->manager->expelUnreferencedCheckpointItems());
1896+
EXPECT_EQ(0, this->global_stats.itemsExpelledFromCheckpoints);
18921897
}

0 commit comments

Comments
 (0)