pub struct RocksDBTuningParameters {Show 16 fields
pub compaction_style: CompactionStyle,
pub optimize_compaction_memtable_budget: usize,
pub level_compaction_dynamic_level_bytes: bool,
pub universal_compaction_target_ratio: i32,
pub parallelism: Option<i32>,
pub compression_type: CompressionType,
pub bottommost_compression_type: CompressionType,
pub batch_size: usize,
pub retry_max_duration: Duration,
pub stats_log_interval_seconds: u32,
pub stats_persist_interval_seconds: u32,
pub point_lookup_block_cache_size_mb: Option<u32>,
pub shrink_buffers_by_ratio: usize,
pub write_buffer_manager_memory_bytes: Option<usize>,
pub write_buffer_manager_memory_fraction: Option<f64>,
pub write_buffer_manager_allow_stall: bool,
}Expand description
A set of parameters to tune RocksDB. This struct is plain-old-data, and is
used to update RocksDBConfig, which contains some dynamic value for some
parameters.
Fields§
§compaction_style: CompactionStyleRocksDB has 2 primary styles of compaction:
- The default, usually referred to as “level” compaction
- “universal”
Universal is simpler and for some workloads could be
better. Also, you can directly configure its space-amplification ratio
(using universal_compaction_target_ratio). However, its unclear
if the UPSERT workload is a good workload for universal compaction,
and its also might be the case that universal compaction uses significantly
more space temporarily while performing compaction.
For these reasons, the default is CompactionStyle::Level.
optimize_compaction_memtable_budget: usizeThe RocksDB api offers a single configuration method that sets some
reasonable defaults for heavy-write workloads, either
https://docs.rs/rocksdb/latest/rocksdb/struct.Options.html#method.optimize_level_style_compaction
or
https://docs.rs/rocksdb/latest/rocksdb/struct.Options.html#method.optimize_universal_style_compaction
depending on compaction_style. We ALSO enable this configuration, which is tuned
by the size of the memtable (basically the in-memory buffer used to avoid IO). The default
here is ~512MB, which is the default from here: https://github.com/facebook/rocksdb/blob/main/include/rocksdb/options.h#L102,
and about twice the global RocksDB default.
level_compaction_dynamic_level_bytes: boolThis option, when enabled, dynamically tunes
the size of the various LSM levels to put a bound on space-amplification.
With the default level-ratio of 10, this means space-amplification is
O(1.11 * the size of data). Note this is big-O notation, and the actual
amplification factor depends on the workload.
See https://www.eecg.toronto.edu/~stumm/Papers/Dong-CIDR-16.pdf for more details.
This option defaults to true, as its basically free saved-space, and only applies to
CompactionStyle::Level.
universal_compaction_target_ratio: i32The additional space-amplification used with universal compaction.
Only applies to CompactionStyle::Universal.
See compaction_style for more information.
parallelism: Option<i32>By default, RocksDB uses only 1 thread to perform compaction and other background tasks.
The default here is the number of cores, as mentioned by https://docs.rs/rocksdb/latest/rocksdb/struct.Options.html#method.increase_parallelism.
Note that this option is shared across all RocksDB instances that share a rocksdb::Env.
compression_type: CompressionTypeThe most important way to reduce space amplification in RocksDB is compression.
In RocksDB, data on disk is stored in an LSM tree. Because the higher layers (which are
smaller) will need to be read during reads that aren’t cached, we want a relatively
lightweight compression scheme, choosing Lz4 as the default, which is considered almost
always better than Snappy.
The meat of the data is stored in the largest, bottom layer, which can be configured
(using bottommost_compression_type) to use a more expensive compression scheme to save
more space. The default is Zstd, which many think has the best compression ratio. Note
that tuning the bottommost layer separately only makes sense when you have free cpu,
which we have in the case of the UPSERT usecase.
bottommost_compression_type: CompressionTypeSee compression_type for more information.
batch_size: usizeThe size of the multi_get and multi_put batches sent to RocksDB. The default is 1024.
retry_max_duration: DurationThe maximum duration for the retries when performing rocksdb actions in case of retry-able errors.
stats_log_interval_seconds: u32The interval to dump stats in LOG.
stats_persist_interval_seconds: u32The interval to persist stats into rocksdb.
point_lookup_block_cache_size_mb: Option<u32>The optional block cache size in MiB for optimizing rocksdb for point lookups. If not provided there will be no optimization. https://github.com/facebook/rocksdb/blob/main/include/rocksdb/options.h#L82-L85
shrink_buffers_by_ratio: usizeThe number of times by which unused buffers will be reduced. For example, if the number is 2, the buffers will be reduced to being twice as small, i.e. halved. Shrinking will be disabled if value is 0;
write_buffer_manager_memory_bytes: Option<usize>Optional write buffer manager bytes. This needs to be set to enable write buffer manager across all rocksdb instances
write_buffer_manager_memory_fraction: Option<f64>Optional write buffer manager memory limit as a percentage of cluster limit
write_buffer_manager_allow_stall: boolConfig to enable stalls with write buffer manager
Implementations§
Source§impl RocksDBTuningParameters
impl RocksDBTuningParameters
Sourcepub fn from_parameters(
compaction_style: CompactionStyle,
optimize_compaction_memtable_budget: usize,
level_compaction_dynamic_level_bytes: bool,
universal_compaction_target_ratio: i32,
parallelism: Option<i32>,
compression_type: CompressionType,
bottommost_compression_type: CompressionType,
batch_size: usize,
retry_max_duration: Duration,
stats_log_interval_seconds: u32,
stats_persist_interval_seconds: u32,
point_lookup_block_cache_size_mb: Option<u32>,
shrink_buffers_by_ratio: usize,
write_buffer_manager_memory_bytes: Option<usize>,
write_buffer_manager_memory_fraction: Option<f64>,
write_buffer_manager_allow_stall: bool,
) -> Result<Self, Error>
pub fn from_parameters( compaction_style: CompactionStyle, optimize_compaction_memtable_budget: usize, level_compaction_dynamic_level_bytes: bool, universal_compaction_target_ratio: i32, parallelism: Option<i32>, compression_type: CompressionType, bottommost_compression_type: CompressionType, batch_size: usize, retry_max_duration: Duration, stats_log_interval_seconds: u32, stats_persist_interval_seconds: u32, point_lookup_block_cache_size_mb: Option<u32>, shrink_buffers_by_ratio: usize, write_buffer_manager_memory_bytes: Option<usize>, write_buffer_manager_memory_fraction: Option<f64>, write_buffer_manager_allow_stall: bool, ) -> Result<Self, Error>
Build a RocksDBTuningParameters from strings and values from LD parameters.
Trait Implementations§
Source§impl Clone for RocksDBTuningParameters
impl Clone for RocksDBTuningParameters
Source§fn clone(&self) -> RocksDBTuningParameters
fn clone(&self) -> RocksDBTuningParameters
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more