Skip to content

Commit e72f0e7

Browse files
jameseh96daverigby
authored andcommitted
RocksDB: Pull some RocksDB config options out into configuration.json
Change-Id: I9a60f44eebab31967bb0e02e591322aaf12fbf24 Reviewed-on: http://review.couchbase.org/82748 Reviewed-by: Dave Rigby <[email protected]> Tested-by: Build Bot <[email protected]>
1 parent 9f5e3d4 commit e72f0e7

File tree

5 files changed

+87
-4
lines changed

5 files changed

+87
-4
lines changed

engines/ep/configuration.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -807,6 +807,39 @@
807807
"descr": "Perform a file sync() operation after every N bytes written. Disabled if set to 0.",
808808
"type" : "size_t"
809809
},
810+
"rocksdb_write_buffer_size": {
811+
"default": "64",
812+
"descr": "The maximum size in MB of a single memtable in rocksdb.",
813+
"type": "size_t",
814+
"validator": {
815+
"range": {
816+
"max": 100000,
817+
"min": 0
818+
}
819+
}
820+
},
821+
"rocksdb_db_write_buffer_size": {
822+
"default": "0",
823+
"descr": "The maximum total size in MB of all memtables in rocksdb, per shard.",
824+
"type": "size_t",
825+
"validator": {
826+
"range": {
827+
"max": 100000,
828+
"min": 0
829+
}
830+
}
831+
},
832+
"rocksdb_max_write_buffer_number": {
833+
"default": "0",
834+
"descr": "The maximum number of memtables in rocksdb before stalling writes, per shard.",
835+
"type": "size_t",
836+
"validator": {
837+
"range": {
838+
"max": 100000,
839+
"min": 0
840+
}
841+
}
842+
},
810843
"time_synchronization": {
811844
"default": "disabled",
812845
"descr": "No longer supported. This config parameter has no effect.",

engines/ep/src/kvstore_config.cc

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ KVStoreConfig::KVStoreConfig(Configuration& config, uint16_t shardid)
3939
config.getDbname(),
4040
config.getBackend(),
4141
shardid,
42-
config.isCollectionsPrototypeEnabled()) {
42+
config.isCollectionsPrototypeEnabled(),
43+
config.getRocksdbWriteBufferSize(),
44+
config.getRocksdbDbWriteBufferSize(),
45+
config.getRocksdbMaxWriteBufferNumber()) {
4346
setPeriodicSyncBytes(config.getFsyncAfterEveryNBytesWritten());
4447
config.addValueChangedListener("fsync_after_every_n_bytes_written",
4548
new ConfigChangeListener(*this));
@@ -50,15 +53,21 @@ KVStoreConfig::KVStoreConfig(uint16_t _maxVBuckets,
5053
const std::string& _dbname,
5154
const std::string& _backend,
5255
uint16_t _shardId,
53-
bool _persistDocNamespace)
56+
bool _persistDocNamespace,
57+
size_t writeBufferSize,
58+
size_t dbWriteBufferSize,
59+
size_t maxWriteBufferNumber)
5460
: maxVBuckets(_maxVBuckets),
5561
maxShards(_maxShards),
5662
dbname(_dbname),
5763
backend(_backend),
5864
shardId(_shardId),
5965
logger(&global_logger),
6066
buffered(true),
61-
persistDocNamespace(_persistDocNamespace) {
67+
persistDocNamespace(_persistDocNamespace),
68+
writeBufferSize(writeBufferSize),
69+
dbWriteBufferSize(dbWriteBufferSize),
70+
maxWriteBufferNumber(maxWriteBufferNumber) {
6271
}
6372

6473
KVStoreConfig& KVStoreConfig::setLogger(Logger& _logger) {

engines/ep/src/kvstore_config.h

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,10 @@ class KVStoreConfig {
4444
const std::string& _dbname,
4545
const std::string& _backend,
4646
uint16_t _shardId,
47-
bool persistDocNamespace);
47+
bool persistDocNamespace,
48+
size_t writeBufferSize = 0,
49+
size_t dbWriteBufferSize = 0,
50+
size_t maxWriteBufferNumber = 0);
4851

4952
uint16_t getMaxVBuckets() const {
5053
return maxVBuckets;
@@ -108,6 +111,28 @@ class KVStoreConfig {
108111
periodicSyncBytes = bytes;
109112
}
110113

114+
/**
115+
* RocksDB: The maximum size in MB of a single memtable.
116+
*/
117+
size_t getWriteBufferSize() {
118+
return writeBufferSize;
119+
}
120+
121+
/**
122+
* RocksDB: The maximum total size in MB of all memtables, per shard.
123+
*/
124+
size_t getDbWriteBufferSize() {
125+
return dbWriteBufferSize;
126+
}
127+
128+
/**
129+
* RocksDB: The maximum number of memtables before stalling writes, per
130+
* shard.
131+
*/
132+
size_t getMaxWriteBufferNumber() {
133+
return maxWriteBufferNumber;
134+
}
135+
111136
private:
112137
class ConfigChangeListener;
113138

@@ -125,4 +150,8 @@ class KVStoreConfig {
125150
* N bytes written.
126151
*/
127152
uint64_t periodicSyncBytes;
153+
154+
size_t writeBufferSize;
155+
size_t dbWriteBufferSize;
156+
size_t maxWriteBufferNumber;
128157
};

engines/ep/src/rocksdb-kvstore/rocksdb-kvstore.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ RocksDBKVStore::~RocksDBKVStore() {
5353
void RocksDBKVStore::open() {
5454
rdbOptions.create_if_missing = true;
5555
rdbOptions.create_missing_column_families = true;
56+
rdbOptions.write_buffer_size =
57+
1024 * 1024 * configuration.getWriteBufferSize();
58+
rdbOptions.db_write_buffer_size =
59+
1024 * 1024 * configuration.getDbWriteBufferSize();
60+
rdbOptions.max_write_buffer_number =
61+
configuration.getMaxWriteBufferNumber();
5662

5763
seqnoCFOptions.comparator = &vbidSeqnoComparator;
5864

engines/ep/tests/ep_testsuite.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6421,6 +6421,9 @@ static enum test_result test_mb19687_fixed(ENGINE_HANDLE* h,
64216421
"ep_replication_throttle_cap_pcnt",
64226422
"ep_replication_throttle_queue_cap",
64236423
"ep_replication_throttle_threshold",
6424+
"ep_rocksdb_db_write_buffer_size",
6425+
"ep_rocksdb_max_write_buffer_number",
6426+
"ep_rocksdb_write_buffer_size",
64246427
"ep_time_synchronization",
64256428
"ep_uuid",
64266429
"ep_vb0",
@@ -6664,6 +6667,9 @@ static enum test_result test_mb19687_fixed(ENGINE_HANDLE* h,
66646667
"ep_replication_throttle_cap_pcnt",
66656668
"ep_replication_throttle_queue_cap",
66666669
"ep_replication_throttle_threshold",
6670+
"ep_rocksdb_db_write_buffer_size",
6671+
"ep_rocksdb_max_write_buffer_number",
6672+
"ep_rocksdb_write_buffer_size",
66676673
"ep_rollback_count",
66686674
"ep_startup_time",
66696675
"ep_storage_age",

0 commit comments

Comments
 (0)