Skip to content

Commit 89617e6

Browse files
BenHuddlestondaverigby
authored andcommitted
MB-39745: Scale bgFetchers independently of KVShards
Add a "max_num_bgfetchers" config param for the number of bg fetchers that we want to create. Change-Id: Ibaeb5e348239d87d3704a44720b3af02fdc4bf2d Reviewed-on: http://review.couchbase.org/c/kv_engine/+/136378 Tested-by: Build Bot <[email protected]> Reviewed-by: Dave Rigby <[email protected]>
1 parent dc283c8 commit 89617e6

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

engines/ep/configuration.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -664,6 +664,12 @@
664664
"dynamic": false,
665665
"type": "size_t"
666666
},
667+
"max_num_bgfetchers": {
668+
"default": "0",
669+
"descr": "Maximum number of bg fetcher objects (the number of concurrent bg fetch tasks we can run). 0 = auto-configure which means we use the same number as the number of shards (max_num_shards - for historic reasons). See also num_reader_threads.",
670+
"dynamic": false,
671+
"type": "size_t"
672+
},
667673
"max_num_shards": {
668674
"default": "0",
669675
"descr": "Maximum mumber of shards (0 = auto-configure)",

engines/ep/src/ep_bucket.cc

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,16 @@ EPBucket::EPBucket(EventuallyPersistentEngine& theEngine)
266266
engine.getConfiguration(), stats);
267267

268268
vbMap.enablePersistence(*this);
269-
for (size_t i = 0; i < vbMap.getNumShards(); i++) {
269+
270+
// Pre-7.0.0 BgFetchers were a part of KVShard so keep the same default
271+
// scaling.
272+
auto configBgFetcherLimit = config.getMaxNumBgfetchers();
273+
auto bgFetcherLimit = configBgFetcherLimit == 0 ? vbMap.getNumShards()
274+
: configBgFetcherLimit;
275+
276+
// Limit BgFetchers by the number of vBuckets as any more would be useless.
277+
bgFetcherLimit = std::min(bgFetcherLimit, config.getMaxVbuckets());
278+
for (size_t i = 0; i < bgFetcherLimit; i++) {
270279
bgFetchers.emplace_back(std::make_unique<BgFetcher>(*this));
271280
}
272281

engines/ep/tests/ep_testsuite.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7049,6 +7049,7 @@ static enum test_result test_mb19687_fixed(EngineIface* h) {
70497049
"ep_magma_initial_wal_buffer_size",
70507050
"ep_magma_write_cache_ratio",
70517051
"ep_magma_expiry_purger_interval",
7052+
"ep_max_num_bgfetchers",
70527053
"ep_max_checkpoints",
70537054
"ep_max_failover_entries",
70547055
"ep_max_item_privileged_bytes",
@@ -7264,6 +7265,7 @@ static enum test_result test_mb19687_fixed(EngineIface* h) {
72647265
"ep_items_rm_from_checkpoints",
72657266
"ep_keep_closed_chks",
72667267
"ep_kv_size",
7268+
"ep_max_num_bgfetchers",
72677269
"ep_max_checkpoints",
72687270
"ep_max_failover_entries",
72697271
"ep_max_item_privileged_bytes",

0 commit comments

Comments
 (0)