-
Notifications
You must be signed in to change notification settings - Fork 26
perf(storage): tune RocksDB options #380
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,7 +4,8 @@ use crate::api::{ | |
| ALL_TABLES, Error, PrefixResult, StorageBackend, StorageReadView, StorageWriteBatch, Table, | ||
| }; | ||
| use rocksdb::{ | ||
| ColumnFamilyDescriptor, DBWithThreadMode, MultiThreaded, Options, WriteBatch, WriteOptions, | ||
| BlockBasedOptions, Cache, ColumnFamilyDescriptor, DBWithThreadMode, MultiThreaded, Options, | ||
| WriteBatch, WriteOptions, | ||
| }; | ||
| use std::path::Path; | ||
| use std::sync::Arc; | ||
|
|
@@ -34,9 +35,29 @@ impl RocksDBBackend { | |
| opts.create_if_missing(true); | ||
| opts.create_missing_column_families(true); | ||
|
|
||
| opts.set_max_open_files(-1); | ||
| opts.set_max_file_opening_threads(8); | ||
| opts.set_max_background_jobs(8); | ||
| opts.set_max_subcompactions(2); | ||
| opts.set_compaction_readahead_size(4 * 1024 * 1024); | ||
| opts.set_level_compaction_dynamic_level_bytes(true); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Prompt To Fix With AIThis is a comment left during a code review.
Path: crates/storage/src/backend/rocksdb.rs
Line: 43
Comment:
`set_level_compaction_dynamic_level_bytes` applied to the wrong options object — the named column families won't use it. `open_cf_descriptors` treats the first `opts` argument as DB-level settings; each CF is configured solely by its own `ColumnFamilyDescriptor` options (`cf_opts = Options::default()` in the closure). Setting this flag on `opts` only influences the default column family (which this code never opens). To activate the optimization on all CFs, move the call into the closure where `cf_opts` is configured.
How can I resolve this? If you propose a fix, please make it concise. |
||
| opts.set_bytes_per_sync(32 * 1024 * 1024); | ||
| opts.set_wal_bytes_per_sync(32 * 1024 * 1024); | ||
| opts.set_max_total_wal_size(256 * 1024 * 1024); | ||
| opts.set_use_fsync(false); | ||
| opts.set_enable_pipelined_write(true); | ||
|
|
||
| let block_cache = Cache::new_lru_cache(128 * 1024 * 1024); | ||
| let mut block_opts = BlockBasedOptions::default(); | ||
| block_opts.set_block_cache(&block_cache); | ||
|
|
||
| let cf_descriptors: Vec<_> = ALL_TABLES | ||
| .iter() | ||
| .map(|t| ColumnFamilyDescriptor::new(cf_name(*t), Options::default())) | ||
| .map(|t| { | ||
| let mut cf_opts = Options::default(); | ||
| cf_opts.set_block_based_table_factory(&block_opts); | ||
| ColumnFamilyDescriptor::new(cf_name(*t), cf_opts) | ||
| }) | ||
| .collect(); | ||
|
|
||
| let db = | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
set_max_file_opening_threadshas no effect whenmax_open_filesis-1. With unlimited open files, RocksDB keeps every SST file descriptor open indefinitely and never invokes the thread-pool-limited re-open path. The call is harmless but misleading; removing it reduces noise.Prompt To Fix With AI