Add min_flusher_count configuration

rel-0.5
Vitaliy Filippov 2021-03-24 01:58:33 +03:00
parent ad9f619370
commit 8f8b90be7a
7 changed files with 28 additions and 20 deletions

View File

@ -53,7 +53,6 @@ ExecStart=/usr/bin/vitastor-osd \\
--osd_num $OSD_NUM \\ --osd_num $OSD_NUM \\
--disable_data_fsync 1 \\ --disable_data_fsync 1 \\
--immediate_commit all \\ --immediate_commit all \\
--flusher_count 256 \\
--disk_alignment 4096 --journal_block_size 4096 --meta_block_size 4096 \\ --disk_alignment 4096 --journal_block_size 4096 --meta_block_size 4096 \\
--journal_no_same_sector_overwrites true \\ --journal_no_same_sector_overwrites true \\
--journal_sector_buffer_count 1024 \\ --journal_sector_buffer_count 1024 \\

View File

@ -92,7 +92,8 @@ const etcd_tree = {
disable_device_lock, disable_device_lock,
// blockstore - configurable // blockstore - configurable
max_write_iodepth, max_write_iodepth,
flusher_count, min_flusher_count: 1,
max_flusher_count: 256,
inmemory_metadata, inmemory_metadata,
inmemory_journal, inmemory_journal,
journal_sector_buffer_count, journal_sector_buffer_count,

View File

@ -3,12 +3,13 @@
#include "blockstore_impl.h" #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->bs = bs;
this->flusher_count = flusher_count; this->max_flusher_count = bs->max_flusher_count;
this->cur_flusher_count = 1; this->min_flusher_count = bs->min_flusher_count;
this->target_flusher_count = 1; this->cur_flusher_count = bs->min_flusher_count;
this->target_flusher_count = bs->min_flusher_count;
dequeuing = false; dequeuing = false;
trimming = false; trimming = false;
active_flushers = 0; active_flushers = 0;
@ -19,8 +20,8 @@ journal_flusher_t::journal_flusher_t(int flusher_count, blockstore_impl_t *bs)
journal_trim_counter = 0; journal_trim_counter = 0;
trim_wanted = 0; trim_wanted = 0;
journal_superblock = bs->journal.inmemory ? bs->journal.buffer : memalign_or_die(MEM_ALIGNMENT, bs->journal_block_size); journal_superblock = bs->journal.inmemory ? bs->journal.buffer : memalign_or_die(MEM_ALIGNMENT, bs->journal_block_size);
co = new journal_flusher_co[flusher_count]; co = new journal_flusher_co[max_flusher_count];
for (int i = 0; i < flusher_count; i++) for (int i = 0; i < max_flusher_count; i++)
{ {
co[i].bs = bs; co[i].bs = bs;
co[i].flusher = this; co[i].flusher = this;
@ -71,10 +72,10 @@ bool journal_flusher_t::is_active()
void journal_flusher_t::loop() void journal_flusher_t::loop()
{ {
target_flusher_count = bs->write_iodepth*2; target_flusher_count = bs->write_iodepth*2;
if (target_flusher_count <= 0) if (target_flusher_count < min_flusher_count)
target_flusher_count = 1; target_flusher_count = min_flusher_count;
else if (target_flusher_count > flusher_count) else if (target_flusher_count > max_flusher_count)
target_flusher_count = flusher_count; target_flusher_count = max_flusher_count;
if (target_flusher_count > cur_flusher_count) if (target_flusher_count > cur_flusher_count)
cur_flusher_count = target_flusher_count; cur_flusher_count = target_flusher_count;
else if (target_flusher_count < cur_flusher_count) else if (target_flusher_count < cur_flusher_count)

View File

@ -80,7 +80,7 @@ class journal_flusher_t
{ {
int trim_wanted = 0; int trim_wanted = 0;
bool dequeuing; 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; int flusher_start_threshold;
journal_flusher_co *co; journal_flusher_co *co;
blockstore_impl_t *bs; blockstore_impl_t *bs;
@ -99,7 +99,7 @@ class journal_flusher_t
std::deque<object_id> flush_queue; std::deque<object_id> flush_queue;
std::map<object_id, uint64_t> flush_versions; std::map<object_id, uint64_t> flush_versions;
public: public:
journal_flusher_t(int flusher_count, blockstore_impl_t *bs); journal_flusher_t(blockstore_impl_t *bs);
~journal_flusher_t(); ~journal_flusher_t();
void loop(); void loop();
bool is_active(); bool is_active();

View File

@ -31,7 +31,7 @@ blockstore_impl_t::blockstore_impl_t(blockstore_config_t & config, ring_loop_t *
close(journal.fd); close(journal.fd);
throw; throw;
} }
flusher = new journal_flusher_t(flusher_count, this); flusher = new journal_flusher_t(this);
} }
blockstore_impl_t::~blockstore_impl_t() blockstore_impl_t::~blockstore_impl_t()

View File

@ -197,8 +197,8 @@ class blockstore_impl_t
// Suitable only for server SSDs with capacitors, requires disabled data and journal fsyncs // Suitable only for server SSDs with capacitors, requires disabled data and journal fsyncs
int immediate_commit = IMMEDIATE_NONE; int immediate_commit = IMMEDIATE_NONE;
bool inmemory_meta = false; bool inmemory_meta = false;
// Maximum flusher count // Maximum and minimum flusher count
unsigned flusher_count; unsigned max_flusher_count, min_flusher_count;
// Maximum queue depth // Maximum queue depth
unsigned max_write_iodepth = 128; unsigned max_write_iodepth = 128;
/******* END OF OPTIONS *******/ /******* END OF OPTIONS *******/

View File

@ -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); journal_block_size = strtoull(config["journal_block_size"].c_str(), NULL, 10);
meta_block_size = strtoull(config["meta_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); 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); max_write_iodepth = strtoull(config["max_write_iodepth"].c_str(), NULL, 10);
// Validate // Validate
if (!block_size) if (!block_size)
@ -80,9 +83,13 @@ void blockstore_impl_t::parse_config(blockstore_config_t & config)
{ {
throw std::runtime_error("Bad block size"); 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) if (!max_write_iodepth)
{ {