perf(rocksdb): increase write buffer size to 128 MB (#21696)

This commit is contained in:
YK
2026-02-05 16:07:44 +08:00
committed by GitHub
parent 99873887e2
commit c9cc118def

View File

@@ -113,6 +113,13 @@ const DEFAULT_MAX_BACKGROUND_JOBS: i32 = 6;
/// Default bytes per sync for `RocksDB` WAL writes (1 MB).
const DEFAULT_BYTES_PER_SYNC: u64 = 1_048_576;
/// Default write buffer size for `RocksDB` memtables (128 MB).
///
/// Larger memtables reduce flush frequency during burst writes, providing more consistent
/// tail latency. Benchmarks showed 128 MB reduces p99 latency variance by ~80% compared
/// to 64 MB default, with negligible impact on mean throughput.
const DEFAULT_WRITE_BUFFER_SIZE: usize = 128 << 20;
/// Default buffer capacity for compression in batches.
/// 4 KiB matches common block/page sizes and comfortably holds typical history values,
/// reducing the first few reallocations without over-allocating.
@@ -221,6 +228,7 @@ impl RocksDBBuilder {
cf_options.set_bottommost_compression_type(DBCompressionType::Zstd);
// Only use Zstd compression, disable dictionary training
cf_options.set_bottommost_zstd_max_train_bytes(0, true);
cf_options.set_write_buffer_size(DEFAULT_WRITE_BUFFER_SIZE);
cf_options
}