diff --git a/crates/storage/provider/src/providers/rocksdb/provider.rs b/crates/storage/provider/src/providers/rocksdb/provider.rs index 2210aa46e7..40f05d8bb5 100644 --- a/crates/storage/provider/src/providers/rocksdb/provider.rs +++ b/crates/storage/provider/src/providers/rocksdb/provider.rs @@ -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 }