From 01c3532ca05986a4178dbf1d9adf3a847232ffa2 Mon Sep 17 00:00:00 2001 From: Alex Robinson Date: Thu, 30 Nov 2017 12:48:50 -0500 Subject: [PATCH] libroach: Set bytes_per_sync to smooth out disk usage This depends on also getting our build flags fixed -- `bytes_per_sync` doesn't work without `-DROCKSDB_RANGESYNC_PRESENT` being set. The 512KB option is somewhat arbitrary, but was chosen as the best value for certain configurations by resources such as https://www.youtube.com/watch?v=pvUqbIeoPzM and https://www.percona.com/live/data-performance-conference-2016/sites/default/files/slides/Percona_RocksDB_v1.3.pdf Also, I'm trying to upstream the related `max_background_jobs` change I mentioned in #19436: https://github.com/facebook/rocksdb/pull/3208. If they don't take that upstream, I'll change it here. Helps with #19436. Release note (performance improvement): Smoothen out disk usage under very write heavy workloads by syncing to disk more frequently. --- c-deps/libroach/db.cc | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/c-deps/libroach/db.cc b/c-deps/libroach/db.cc index 2ffb2d59b21d..8c4d74eaf2fd 100644 --- a/c-deps/libroach/db.cc +++ b/c-deps/libroach/db.cc @@ -1537,10 +1537,9 @@ rocksdb::Options DBMakeOptions(DBOptions db_opts) { // Use the rocksdb options builder to configure the base options // using our memtable budget. rocksdb::Options options; - // Increase parallelism for compactions based on the number of - // cpus. This will use 1 high priority thread for flushes and - // num_cpu-1 low priority threads for compactions. Always use at - // least 2 threads, otherwise compactions won't happen. + // Increase parallelism for compactions and flushes based on the + // number of cpus. Always use at least 2 threads, otherwise + // compactions and flushes may fight with each other. options.IncreaseParallelism(std::max(db_opts.num_cpu, 2)); // Enable subcompactions which will use multiple threads to speed up // a single compaction. The value of num_cpu/2 has not been tuned. @@ -1554,14 +1553,11 @@ rocksdb::Options DBMakeOptions(DBOptions db_opts) { options.statistics = rocksdb::CreateDBStatistics(); options.max_open_files = db_opts.max_open_files; options.compaction_pri = rocksdb::kMinOverlappingRatio; - // Periodically sync the WAL to smooth out writes. Not performing - // such syncs can be faster but can cause performance blips when the - // OS decides it needs to flush data. - options.wal_bytes_per_sync = 256 << 10; // 256 KB - - // Periodically sync sstables during compaction to smooth out - // writes. Experimentally this has had no effect. - // options.bytes_per_sync = 4 << 20; + // Periodically sync both the WAL and SST writes to smooth out disk + // usage. Not performing such syncs can be faster but can cause + // performance blips when the OS decides it needs to flush data. + options.wal_bytes_per_sync = 512 << 10; // 512 KB + options.bytes_per_sync = 512 << 10; // 512 KB // The size reads should be performed in for compaction. The // internets claim this can speed up compactions, though RocksDB