Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions crates/storage/src/backend/rocksdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Comment on lines +38 to +39
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 set_max_file_opening_threads has no effect when max_open_files is -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.

Suggested change
opts.set_max_open_files(-1);
opts.set_max_file_opening_threads(8);
opts.set_max_open_files(-1);
Prompt To Fix With AI
This is a comment left during a code review.
Path: crates/storage/src/backend/rocksdb.rs
Line: 38-39

Comment:
`set_max_file_opening_threads` has no effect when `max_open_files` is `-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.

```suggestion
        opts.set_max_open_files(-1);
```

How can I resolve this? If you propose a fix, please make it concise.

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);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 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.

Prompt To Fix With AI
This 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 =
Expand Down
Loading