Skip to content

[FLUSS] Support shared RocksDB block cache across KV tablets - #2627

Merged
luoyuxia merged 1 commit into
apache:mainfrom
platinumhamburg:shared-block-cache
Sep 1, 2026
Merged

luoyuxia merged 1 commit into
apache:mainfrom
platinumhamburg:shared-block-cache

Conversation

@platinumhamburg

@platinumhamburg platinumhamburg commented Feb 10, 2026 •

Copy link
Copy Markdown
Contributor

Introduce a TabletServer-level shared LRUCache for all KV tablets, controlled by kv.rocksdb.shared-block-cache.size.

  • Add kv.rocksdb.shared-block-cache.enabled and .size config options
  • KvManager creates/manages shared cache lifecycle
  • RocksDBResourceContainer accepts optional external cache
  • Adapt RocksDBStatistics to avoid double-counting shared cache in metrics
  • TabletServerMetricGroup includes shared cache usage once in total
  • Update config and metrics documentation

Purpose

Linked issue: close #1319

Brief change log

Tests

API and Format

Documentation

@platinumhamburg
platinumhamburg force-pushed the shared-block-cache branch 2 times, most recently from ad2ebda to c849677 Compare July 21, 2026 03:17
Introduce a TabletServer-level shared LRUCache for KV tablets, controlled by kv.rocksdb.shared-block-cache.size. A value of zero keeps the existing per-tablet caches, while a positive value enables one shared cache with that soft capacity.

Manage the cache lifecycle in KvManager, avoid double-counting shared cache memory in table metrics, expose server-level usage, pinned usage, and capacity metrics, and document the configuration and observability semantics.

Copilot AI left a comment

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.

Pull request overview

This PR adds an optional TabletServer-scoped shared RocksDB LRUCache to be used as the block cache across all KV tablets, aiming to better control/optimize memory usage as table count grows (Issue #1319). It also updates metrics aggregation to avoid double-counting when a cache is shared, and documents the new behavior.

Changes:

  • Introduce a TabletServer-level shared RocksDB block cache created/owned by KvManager and passed down into KvTablet/RocksDBResourceContainer when enabled via config.
  • Extend server-level metrics to report shared block cache usage/capacity/pinned usage once, and adjust total memory aggregation accordingly.
  • Add/extend tests and documentation for the shared-cache configuration and the updated metrics semantics.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
website/docs/maintenance/observability/monitor-metrics.md Document new server-level shared block cache metrics and clarify total-memory aggregation semantics.
website/docs/maintenance/configuration.md Document kv.rocksdb.shared-block-cache.size and clarify interaction with per-instance kv.rocksdb.block.cache-size.
fluss-server/src/test/java/org/apache/fluss/server/metrics/group/TabletServerMetricGroupTest.java Add unit test ensuring server total memory counts shared cache once and shared-cache metrics are exposed.
fluss-server/src/test/java/org/apache/fluss/server/kv/rocksdb/RocksDBResourceContainerTest.java Add tests for shared cache wiring/lifecycle and independent cache closure behavior.
fluss-server/src/test/java/org/apache/fluss/server/kv/KvTabletTest.java Update test construction signature and strengthen RocksDB memory-metric consistency assertions.
fluss-server/src/test/java/org/apache/fluss/server/kv/KvManagerTest.java Add test verifying shared cache is used across multiple KV tablets when configured.
fluss-server/src/main/java/org/apache/fluss/server/metrics/group/TabletServerMetricGroup.java Add shared-cache gauges and incorporate shared cache usage into server total memory metric.
fluss-server/src/main/java/org/apache/fluss/server/kv/rocksdb/RocksDBStatistics.java Avoid double-counting in total memory calculation and clarify semantics when cache is shared/not attributable.
fluss-server/src/main/java/org/apache/fluss/server/kv/rocksdb/RocksDBResourceContainer.java Accept optional external/shared cache and avoid closing it from per-tablet containers.
fluss-server/src/main/java/org/apache/fluss/server/kv/KvTablet.java Thread shared cache into RocksDB construction and omit cache from per-tablet RocksDBStatistics when shared.
fluss-server/src/main/java/org/apache/fluss/server/kv/KvManager.java Create/own shared cache lifecycle, wire it into tablets, and register shared-cache metric suppliers.
fluss-common/src/main/java/org/apache/fluss/metrics/MetricNames.java Add metric name constants for shared block cache usage/capacity/pinned usage.
fluss-common/src/main/java/org/apache/fluss/config/ConfigOptions.java Add kv.rocksdb.shared-block-cache.size config option and clarify kv.rocksdb.block.cache-size behavior with shared cache.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@luoyuxia luoyuxia left a comment

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.

+1

@luoyuxia
luoyuxia merged commit 333dfcc into apache:main Sep 1, 2026
21 checks passed
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.

[KV] Enable shared block cache for RocksDB instances

3 participants