Skip to content

feat(config): remove ineffective RocksDB table setters - #50

Open
bladehan1 wants to merge 1 commit into
developfrom
feature/remove_unverified_rocksdb_config
Open

feat(config): remove ineffective RocksDB table setters#50
bladehan1 wants to merge 1 commit into
developfrom
feature/remove_unverified_rocksdb_config

Conversation

@bladehan1

@bladehan1 bladehan1 commented Aug 14, 2026

Copy link
Copy Markdown
Owner

What does this PR do?

Remove RocksDB block-table setters that were applied after setTableFormatConfig() and therefore never reached the native table factory.

Keep the existing storage.dbSettings.blocksize entries and Java API for compatibility, while documenting in reference.conf that the value is not currently applied to native RocksDB table options.

Add regression tests for the shipped Options-level configuration and the effective native block-table behavior.

Why are these changes required?

setTableFormatConfig() materializes the native table factory from the Java configuration at call time. The later block-size, shared-cache, index/filter-cache, L0-pinning, and Bloom-filter setters only changed the Java object and did not affect the native factory.

Moving those setters before setTableFormatConfig() would activate several unverified settings at once. In a fixed 500-block Mainnet replay, activating the combined settings reduced throughput from 2.421 blocks/s to 1.969 and 1.680 blocks/s, while restoring the pre-change effective native behavior produced 2.418 blocks/s.

This change therefore removes the ineffective setter sequence while preserving the behavior that nodes actually used before the change.

This PR has been tested by:

  • ./gradlew :common:test --tests org.tron.common.setting.RocksDbSettingsTest
  • ./gradlew :framework:test --tests org.tron.core.config.ConfigurationTest
  • ./gradlew :framework:checkstyleMain
  • ./gradlew :framework:checkstyleTest

Follow up

Evaluate block size, Bloom filters, shared-cache capacity, ownership, lifecycle, and observability independently with representative SR and database-specific workloads before enabling another RocksDB table profile.

Extra details

  • blocksize remains configurable and observable for compatibility but is not applied to the native table factory.
  • The existing static shared-cache object and accessor remain for separate configuration design and validation.
  • No API, protocol, database-format, or migration changes are introduced.

Closes #49


Summary by cubic

Uses RocksDB’s native block-table defaults and keeps storage.dbSettings.blocksize only for compatibility. Old behavior set block size, bloom filter, and cached index/filter blocks; new behavior sets no table options (defaults: 4 KB blocks, no bloom, index/filter not cached). No API, protocol, or DB-format changes.

Refactors

  • Remove table-option setters that never reached the native table factory.
  • Document in reference.conf that blocksize is not applied to table options.
  • Add tests to verify native table defaults and preserve effective non-table RocksDB settings.
  • Keep the shared LRU cache for future configuration.

Written for commit a3bab81. Summary will update on new commits.

Review in cubic

@bladehan1 bladehan1 added the type:feature Feature request label Aug 14, 2026
@coderabbitai

coderabbitai Bot commented Aug 14, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: fa2f6e7f-0cd1-41d3-9010-ee4d0fc14be2


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.

@bladehan1
bladehan1 force-pushed the feature/remove_unverified_rocksdb_config branch from bd3ec32 to 50ceeba Compare August 25, 2026 08:22
@bladehan1
bladehan1 marked this pull request as ready for review August 25, 2026 08:22

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

2 issues found across 8 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="common/src/main/java/org/tron/common/setting/RocksDbSettings.java">

<violation number="1" location="common/src/main/java/org/tron/common/setting/RocksDbSettings.java:204">
P3: This change removed the only usage of `RocksDbSettings.getCache()`, so the static `cache` field now allocates a 1 GB native LRUCache on class load that nothing consumes. Remove the `cache` field and the `getCache()` method, or the allocation is wasted native memory on every process.</violation>
</file>

<file name="framework/src/test/java/org/tron/core/config/ConfigurationTest.java">

<violation number="1" location="framework/src/test/java/org/tron/core/config/ConfigurationTest.java:101">
P3: assertFalse(config.hasPath("storage.dbSettings.blocksize")) can never detect a regression because that key does not exist in config.conf, reference.conf, or DbSettingsConfig. The per-database blockSize override lives under storage.properties (DbOptionOverride.blockSize), not storage.dbSettings. Drop the assertion, or if you intend to guard the removal, assert on the namespace that actually carried the option.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread common/src/main/java/org/tron/common/setting/RocksDbSettings.java Outdated
tableCfg.setCacheIndexAndFilterBlocks(true);
tableCfg.setPinL0FilterAndIndexBlocksInCache(true);
tableCfg.setFilter(new BloomFilter(10, false));
options.setTableFormatConfig(new BlockBasedTableConfig());

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P3: This change removed the only usage of RocksDbSettings.getCache(), so the static cache field now allocates a 1 GB native LRUCache on class load that nothing consumes. Remove the cache field and the getCache() method, or the allocation is wasted native memory on every process.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At common/src/main/java/org/tron/common/setting/RocksDbSettings.java, line 204:

<comment>This change removed the only usage of `RocksDbSettings.getCache()`, so the static `cache` field now allocates a 1 GB native LRUCache on class load that nothing consumes. Remove the `cache` field and the `getCache()` method, or the allocation is wasted native memory on every process.</comment>

<file context>
@@ -211,13 +201,7 @@ protected void log(InfoLogLevel infoLogLevel, String logMsg) {
-    tableCfg.setCacheIndexAndFilterBlocks(true);
-    tableCfg.setPinL0FilterAndIndexBlocksInCache(true);
-    tableCfg.setFilter(new BloomFilter(10, false));
+    options.setTableFormatConfig(new BlockBasedTableConfig());
     if (Constant.MARKET_PAIR_PRICE_TO_ORDER.equals(dbName)) {
       ComparatorOptions comparatorOptions = new ComparatorOptions();
</file context>

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

不会直接分配1GB,仅部分元数据

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

The 1 GiB value is the cache capacity limit and is not eagerly allocated as 1 GiB of physical memory. Since the cache is no longer attached to the native table factory, only the cache object and its metadata remain allocated. We will retain the existing field and accessor for compatibility and handle its removal, sizing, and lifecycle separately after validating an appropriate cache configuration.

Config config = Configuration.getByFileName("config.conf");
StorageConfig.DbSettingsConfig settings = StorageConfig.fromConfig(config).getDbSettings();

assertFalse(config.hasPath("storage.dbSettings.blocksize"));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P3: assertFalse(config.hasPath("storage.dbSettings.blocksize")) can never detect a regression because that key does not exist in config.conf, reference.conf, or DbSettingsConfig. The per-database blockSize override lives under storage.properties (DbOptionOverride.blockSize), not storage.dbSettings. Drop the assertion, or if you intend to guard the removal, assert on the namespace that actually carried the option.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At framework/src/test/java/org/tron/core/config/ConfigurationTest.java, line 101:

<comment>assertFalse(config.hasPath("storage.dbSettings.blocksize")) can never detect a regression because that key does not exist in config.conf, reference.conf, or DbSettingsConfig. The per-database blockSize override lives under storage.properties (DbOptionOverride.blockSize), not storage.dbSettings. Drop the assertion, or if you intend to guard the removal, assert on the namespace that actually carried the option.</comment>

<file context>
@@ -91,4 +92,19 @@ public void getConfigurationWhenOnlyConfFileName() {
+    Config config = Configuration.getByFileName("config.conf");
+    StorageConfig.DbSettingsConfig settings = StorageConfig.fromConfig(config).getDbSettings();
+
+    assertFalse(config.hasPath("storage.dbSettings.blocksize"));
+    assertEquals(7, settings.getLevelNumber());
+    assertEquals(256, settings.getMaxBytesForLevelBase());
</file context>
Suggested change
assertFalse(config.hasPath("storage.dbSettings.blocksize"));
// (remove the assertFalse on storage.dbSettings.blocksize; the key was never defined)

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Addressed in a3bab81b05. The storage.dbSettings.blocksize entry is now retained in both config.conf and reference.conf to avoid an unnecessary configuration compatibility change. The configuration test verifies that the shipped value still resolves to 64 KiB, while the native Options test separately verifies that it is not applied to the RocksDB table factory.

@bladehan1
bladehan1 force-pushed the feature/remove_unverified_rocksdb_config branch 2 times, most recently from 9ecc46a to 2594672 Compare August 25, 2026 08:56
Preserve the shipped RocksDB configuration and public block-size API while removing table setters that never reached the native table factory. Document that blocksize is currently ineffective and verify native behavior.

Keep the existing shared cache object for separate configuration design and validation.

Closes #49
@bladehan1
bladehan1 force-pushed the feature/remove_unverified_rocksdb_config branch from 2594672 to a3bab81 Compare August 25, 2026 09:38
dbSettings = {
levelNumber = 7 // Number of RocksDB levels.
compactThreads = 0 // 0 = auto: max(availableProcessors, 1)
# Currently retained for compatibility but not applied to native RocksDB table options.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

[SHOULD] Align the PR metadata with the retained configuration

The PR title and authored What/Why sections still say that the shipped config.conf overrides are removed so reference.conf defaults take effect. At this HEAD, config.conf and the block-size API remain unchanged; the implementation only removes table setters that never reached the native table factory and adds this compatibility note. The current text therefore describes a configuration/default change that does not occur, and its test list also omits RocksDbSettingsTest.

Suggestion: Rename the PR and update What/Why/Tests to describe the retained configuration and API, the removed inactive setters, and the native OPTIONS-* regression test.

@bladehan1 bladehan1 changed the title feat(config): use reference RocksDB defaults feat(config): remove ineffective RocksDB table setters Aug 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:feature Feature request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Remove ineffective RocksDB table option setters

1 participant