This patch substitutes uint64_t for uint32_t as the type for
commitlog_total_space_in_mb. Moving to 64 is not strictly needed, since even a
signed 32-bit type would allow us to easily handle 2TB. But since we store that
in the commitlog as a 64-bit value, let's match it.
Moving from unsigned to signed, however, allow us to represent negative
numbers. With that in place, we can change the semantics of the value
slightly, so to allow a negative number to mean "all memory".
The reason behind this, is that the default value "8GB", is an artifact of the
JVM. We don't need that, and in many-shards configuration, each shard flushes
the commitlog way too often, since 8GB / many_shards = small_number.
8GB also happens to be a popular heap size for C* in the JVM. For us, we would
like to equate that (at least) with the amount of memory. The problem is how to
do that without introducing new options or changing the semantics of existing
options too radically.
The proposed solution will allow us to still parse C* yaml files, since those
will always have positive numbers, while introducing our own defaults.
Signed-off-by: Glauber Costa <
glo...@scylladb.com>
---
db/config.hh | 2 +-
db/commitlog/commitlog.cc | 3 ++-
conf/scylla.yaml | 3 +++
3 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/db/config.hh b/db/config.hh
index a30343c..c153dec 100644
--- a/db/config.hh
+++ b/db/config.hh
@@ -316,7 +316,7 @@ class config {
val(commitlog_sync_batch_window_in_ms, uint32_t, 10000, Used, \
"Controls how long the system waits for other writes before performing a sync in \"batch\" mode." \
) \
- val(commitlog_total_space_in_mb, uint32_t, 8192, Used, \
+ val(commitlog_total_space_in_mb, int64_t, 8192, Used, \
"Total space used for commitlogs. If the used space goes above this value, Cassandra rounds up to the next nearest segment multiple and flushes memtables to disk for the oldest commitlog segments, removing those log segments. This reduces the amount of data to replay on startup, and prevents infrequently-updated tables from indefinitely keeping commitlog segments. A small total commitlog space tends to cause more flush activity on less-active tables.\n" \
"Related information: Configuring memtable throughput" \
) \
diff --git a/db/commitlog/commitlog.cc b/db/commitlog/commitlog.cc
index a0fea10..c9a316e 100644
--- a/db/commitlog/commitlog.cc
+++ b/db/commitlog/commitlog.cc
@@ -55,6 +55,7 @@
#include <core/rwlock.hh>
#include <core/gate.hh>
#include <core/fstream.hh>
+#include <seastar/core/memory.hh>
#include <net/byteorder.hh>
#include "commitlog.hh"
@@ -89,7 +90,7 @@ class crc32_nbo {
db::commitlog::config::config(const db::config& cfg)
: commit_log_location(cfg.commitlog_directory())
- , commitlog_total_space_in_mb(cfg.commitlog_total_space_in_mb())
+ , commitlog_total_space_in_mb(cfg.commitlog_total_space_in_mb() >= 0 ? cfg.commitlog_total_space_in_mb() : memory::stats().total_memory())
, commitlog_segment_size_in_mb(cfg.commitlog_segment_size_in_mb())
, commitlog_sync_period_in_ms(cfg.commitlog_sync_batch_window_in_ms())
, mode(cfg.commitlog_sync() == "batch" ? sync_mode::BATCH : sync_mode::PERIODIC)
diff --git a/conf/scylla.yaml b/conf/scylla.yaml
index 87672df..cef21a4 100644
--- a/conf/scylla.yaml
+++ b/conf/scylla.yaml
@@ -417,6 +417,9 @@ partitioner: org.apache.cassandra.dht.Murmur3Partitioner
# segment multiple), Scylla will flush every dirty CF in the oldest
# segment and remove it. So a small total commitlog space will tend
# to cause more flush activity on less-active columnfamilies.
+#
+# A value of -1 will automatically equate it to the total amount of memory
+# available for Scylla.
commitlog_total_space_in_mb: 8192
# This sets the amount of memtable flush writer threads. These will
--
2.4.3