commitlog: unfold flush threshold assignment

This commit is only a cosmetic change. It is meant to
make the flush threshold assignment more readable and
comprehensible so future changes are easier to review.

Signed-off-by: Eliran Sinvani <eliransin@scylladb.com>
This commit is contained in:
Eliran Sinvani
2022-07-05 16:25:10 +03:00
parent 65e42e4166
commit d2a8651bce

View File

@@ -1380,11 +1380,21 @@ db::commitlog::segment_manager::segment_manager(config c)
, max_mutation_size(max_size >> 1)
, max_disk_size(size_t(std::ceil(cfg.commitlog_total_space_in_mb / double(smp::count))) * 1024 * 1024)
// our threshold for trying to force a flush. needs heristics, for now max - segment_size/2.
, disk_usage_threshold(cfg.commitlog_flush_threshold_in_mb.has_value()
? size_t(std::ceil(*cfg.commitlog_flush_threshold_in_mb / double(smp::count))) * 1024 * 1024
: (max_disk_size -
(max_disk_size >= (max_size*2) ? max_size
: (max_disk_size > (max_size/2) ? (max_size/2) : max_disk_size/3))))
, disk_usage_threshold([&] {
if (cfg.commitlog_flush_threshold_in_mb.has_value()) {
return size_t(std::ceil(*cfg.commitlog_flush_threshold_in_mb / double(smp::count))) * 1024 * 1024;
} else {
if (max_disk_size >= (max_size*2)) {
return max_disk_size - max_size;
} else {
if (max_disk_size > (max_size/2)) {
return max_disk_size - (max_size/2);
} else {
return max_disk_size - max_disk_size/3;
}
}
}
}())
, _flush_semaphore(cfg.max_active_flushes)
// That is enough concurrency to allow for our largest mutation (max_mutation_size), plus
// an existing in-flight buffer. Since we'll force the cycling() of any buffer that is bigger