Skip to content

fix(db): apply rocksdb table config #39

Open
bladehan1 wants to merge 1 commit into
release_v4.8.2from
feat/rocksdb_config
Open

fix(db): apply rocksdb table config #39
bladehan1 wants to merge 1 commit into
release_v4.8.2from
feat/rocksdb_config

Conversation

@bladehan1

@bladehan1 bladehan1 commented Jun 17, 2026

Copy link
Copy Markdown
Owner

What does this PR do?

Fixes a RocksDB option-ordering bug in RocksDbSettings.getOptionsByDbName() so that the BlockBasedTableConfig (table-level) settings actually take effect.

Options.setTableFormatConfig() materializes the native table factory at call time. It was being called before the tableCfg.setXxx() calls, so every table-level setting was silently dropped and RocksDB fell back to defaults:

Option Intended Effective before fix
block_size 16 KB 4096 (default)
block_cache shared 1 GB LRU 8 MB per-db (default)
cache_index_and_filter_blocks true false
pin_l0_filter_and_index_blocks_in_cache true false
filter_policy BloomFilter(10) nullptr (no bloom filter)

The fix moves options.setTableFormatConfig(tableCfg) to be the last call, after all tableCfg setters. Options-level settings (numLevels, maxOpenFiles, comparator, etc.) were unaffected and continue to work.

Why are these changes required?

The intended table tuning never reached the native layer, so on real nodes RocksDB ran with near-worst-case defaults: no bloom filter (slow point lookups), 4 KB blocks (larger index), the shared 1 GB block cache was dead code (each DB used its own 8 MB default), and index/filter blocks were held by table readers instead of the cache. This degrades read performance, especially on large fullnode datasets.

This PR has been tested by:

  • Unit Tests
  • Manual Testing — started a fresh ROCKSDB-engine private chain and confirmed via each DB's OPTIONS-* file that the effective options now match the intended config: block_size=16384, cache_index_and_filter_blocks=true, pin_l0_filter_and_index_blocks_in_cache=true, filter_policy=rocksdb.BuiltinBloomFilter, no_block_cache=false. Node produced blocks normally.

Follow up

  • The 1 GB block cache capacity is hardcoded; large (multi-TB) fullnodes may want it raised (e.g. 2–4 GB) and made operator-configurable.
  • Behavior change: estimate-table-readers-mem drops and block-cache-usage rises after this fix; watch native RSS (≈ +650 MB as the shared cache fills).

Extra details

Compatibility: block_size and bloom filter are SST write-time properties stored per file, read back per each SST's own metadata, so existing data needs no migration — old and new SSTs coexist and the new format is adopted gradually via compaction.


Summary by cubic

Fixes an option ordering bug in RocksDbSettings.getOptionsByDbName() so BlockBasedTableConfig settings are applied by calling options.setTableFormatConfig(tableCfg) last. This enables the intended block size, shared block cache, and bloom filter to take effect, improving read performance.

  • Bug Fixes
    • Reordered Options.setTableFormatConfig() after all tableCfg setters so table options are honored.
    • Verified via OPTIONS-*: block_size=16384, shared cache used, cache_index_and_filter_blocks=true, L0 pinning and bloom filter enabled; no migration needed.

Written for commit 1f16253. Summary will update on new commits.

Review in cubic

…last

setTableFormatConfig() materializes the native table factory at call time,
so the BlockBasedTableConfig setters that followed it were silently dropped:
block size, shared block cache, cache_index_and_filter_blocks, L0 pinning
and the bloom filter all fell back to RocksDB defaults. Move the
setTableFormatConfig() call after all tableCfg setters so they take effect.

Verified on a fresh ROCKSDB private chain: OPTIONS now report block_size=16384,
cache_index_and_filter_blocks=true, pin_l0=true and a BuiltinBloomFilter.
@coderabbitai

coderabbitai Bot commented Jun 17, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 07e3b7ff-0404-4abb-96a7-9cf0eadcfbba

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/rocksdb_config

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

No issues found across 1 file

Re-trigger cubic

@bladehan1 bladehan1 changed the title fix(db): apply rocksdb table config by ordering setTableFormatConfig last fix(db): apply rocksdb table config Jun 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant