From 8f8b90be7acbdbe973ac4e5bc453209fcf4567a4 Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Wed, 24 Mar 2021 01:58:33 +0300 Subject: [PATCH] Add min_flusher_count configuration --- mon/make-osd.sh | 1 - mon/mon.js | 3 ++- src/blockstore_flush.cpp | 21 +++++++++++---------- src/blockstore_flush.h | 4 ++-- src/blockstore_impl.cpp | 2 +- src/blockstore_impl.h | 4 ++-- src/blockstore_open.cpp | 13 ++++++++++--- 7 files changed, 28 insertions(+), 20 deletions(-) diff --git a/mon/make-osd.sh b/mon/make-osd.sh index 271a46020..041fe4479 100755 --- a/mon/make-osd.sh +++ b/mon/make-osd.sh @@ -53,7 +53,6 @@ ExecStart=/usr/bin/vitastor-osd \\ --osd_num $OSD_NUM \\ --disable_data_fsync 1 \\ --immediate_commit all \\ - --flusher_count 256 \\ --disk_alignment 4096 --journal_block_size 4096 --meta_block_size 4096 \\ --journal_no_same_sector_overwrites true \\ --journal_sector_buffer_count 1024 \\ diff --git a/mon/mon.js b/mon/mon.js index c75bb284f..96a836627 100644 --- a/mon/mon.js +++ b/mon/mon.js @@ -92,7 +92,8 @@ const etcd_tree = { disable_device_lock, // blockstore - configurable max_write_iodepth, - flusher_count, + min_flusher_count: 1, + max_flusher_count: 256, inmemory_metadata, inmemory_journal, journal_sector_buffer_count, diff --git a/src/blockstore_flush.cpp b/src/blockstore_flush.cpp index 8d9c428d5..944534065 100644 --- a/src/blockstore_flush.cpp +++ b/src/blockstore_flush.cpp @@ -3,12 +3,13 @@ #include "blockstore_impl.h" -journal_flusher_t::journal_flusher_t(int flusher_count, blockstore_impl_t *bs) +journal_flusher_t::journal_flusher_t(blockstore_impl_t *bs) { this->bs = bs; - this->flusher_count = flusher_count; - this->cur_flusher_count = 1; - this->target_flusher_count = 1; + this->max_flusher_count = bs->max_flusher_count; + this->min_flusher_count = bs->min_flusher_count; + this->cur_flusher_count = bs->min_flusher_count; + this->target_flusher_count = bs->min_flusher_count; dequeuing = false; trimming = false; active_flushers = 0; @@ -19,8 +20,8 @@ journal_flusher_t::journal_flusher_t(int flusher_count, blockstore_impl_t *bs) journal_trim_counter = 0; trim_wanted = 0; journal_superblock = bs->journal.inmemory ? bs->journal.buffer : memalign_or_die(MEM_ALIGNMENT, bs->journal_block_size); - co = new journal_flusher_co[flusher_count]; - for (int i = 0; i < flusher_count; i++) + co = new journal_flusher_co[max_flusher_count]; + for (int i = 0; i < max_flusher_count; i++) { co[i].bs = bs; co[i].flusher = this; @@ -71,10 +72,10 @@ bool journal_flusher_t::is_active() void journal_flusher_t::loop() { target_flusher_count = bs->write_iodepth*2; - if (target_flusher_count <= 0) - target_flusher_count = 1; - else if (target_flusher_count > flusher_count) - target_flusher_count = flusher_count; + if (target_flusher_count < min_flusher_count) + target_flusher_count = min_flusher_count; + else if (target_flusher_count > max_flusher_count) + target_flusher_count = max_flusher_count; if (target_flusher_count > cur_flusher_count) cur_flusher_count = target_flusher_count; else if (target_flusher_count < cur_flusher_count) diff --git a/src/blockstore_flush.h b/src/blockstore_flush.h index c76acf6ea..0bf4ebe05 100644 --- a/src/blockstore_flush.h +++ b/src/blockstore_flush.h @@ -80,7 +80,7 @@ class journal_flusher_t { int trim_wanted = 0; bool dequeuing; - int flusher_count, cur_flusher_count, target_flusher_count; + int min_flusher_count, max_flusher_count, cur_flusher_count, target_flusher_count; int flusher_start_threshold; journal_flusher_co *co; blockstore_impl_t *bs; @@ -99,7 +99,7 @@ class journal_flusher_t std::deque flush_queue; std::map flush_versions; public: - journal_flusher_t(int flusher_count, blockstore_impl_t *bs); + journal_flusher_t(blockstore_impl_t *bs); ~journal_flusher_t(); void loop(); bool is_active(); diff --git a/src/blockstore_impl.cpp b/src/blockstore_impl.cpp index 1ae07da29..c77b427b2 100644 --- a/src/blockstore_impl.cpp +++ b/src/blockstore_impl.cpp @@ -31,7 +31,7 @@ blockstore_impl_t::blockstore_impl_t(blockstore_config_t & config, ring_loop_t * close(journal.fd); throw; } - flusher = new journal_flusher_t(flusher_count, this); + flusher = new journal_flusher_t(this); } blockstore_impl_t::~blockstore_impl_t() diff --git a/src/blockstore_impl.h b/src/blockstore_impl.h index 21a97d49e..eea9c5940 100644 --- a/src/blockstore_impl.h +++ b/src/blockstore_impl.h @@ -197,8 +197,8 @@ class blockstore_impl_t // Suitable only for server SSDs with capacitors, requires disabled data and journal fsyncs int immediate_commit = IMMEDIATE_NONE; bool inmemory_meta = false; - // Maximum flusher count - unsigned flusher_count; + // Maximum and minimum flusher count + unsigned max_flusher_count, min_flusher_count; // Maximum queue depth unsigned max_write_iodepth = 128; /******* END OF OPTIONS *******/ diff --git a/src/blockstore_open.cpp b/src/blockstore_open.cpp index 1b90a2f71..fa1239db7 100644 --- a/src/blockstore_open.cpp +++ b/src/blockstore_open.cpp @@ -69,7 +69,10 @@ void blockstore_impl_t::parse_config(blockstore_config_t & config) journal_block_size = strtoull(config["journal_block_size"].c_str(), NULL, 10); meta_block_size = strtoull(config["meta_block_size"].c_str(), NULL, 10); bitmap_granularity = strtoull(config["bitmap_granularity"].c_str(), NULL, 10); - flusher_count = strtoull(config["flusher_count"].c_str(), NULL, 10); + max_flusher_count = strtoull(config["max_flusher_count"].c_str(), NULL, 10); + if (!max_flusher_count) + max_flusher_count = strtoull(config["flusher_count"].c_str(), NULL, 10); + min_flusher_count = strtoull(config["min_flusher_count"].c_str(), NULL, 10); max_write_iodepth = strtoull(config["max_write_iodepth"].c_str(), NULL, 10); // Validate if (!block_size) @@ -80,9 +83,13 @@ void blockstore_impl_t::parse_config(blockstore_config_t & config) { throw std::runtime_error("Bad block size"); } - if (!flusher_count) + if (!max_flusher_count) { - flusher_count = 32; + max_flusher_count = 256; + } + if (!min_flusher_count) + { + min_flusher_count = 1; } if (!max_write_iodepth) {