[Enhancement](ms) Add sharded LRU cache for tablet index metadata to reduce FDB IO#61666
Draft
wyxxxcat wants to merge 1 commit intoapache:masterfrom
Draft
[Enhancement](ms) Add sharded LRU cache for tablet index metadata to reduce FDB IO#61666wyxxxcat wants to merge 1 commit intoapache:masterfrom
wyxxxcat wants to merge 1 commit intoapache:masterfrom
Conversation
Contributor
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
Collaborator
Author
|
run buildall |
dataroaring
reviewed
Mar 25, 2026
Contributor
There was a problem hiding this comment.
There is already a lru cache in be, we should use it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR implements a sharded LRU cache for
meta_tablet_idx_keylookups in both MetaService and Recycler to reduce frequent FDB reads of immutable metadata.Background
MS-side operations like
commit_rowset,finish_tablet_job, andcommit_txnfrequently read the same tablet index metadata (TabletIndexPB), which is nearly immutable after creation. This causes unnecessary FDB IO overhead.Implementation
Core Components
KvCache Template (
cloud/src/common/kv_cache.h)KeyTupleandValuePBtypesKvCacheManager (
cloud/src/common/kv_cache_manager.h)Configuration (
cloud/src/common/config.h)ms_tablet_index_cache_capacity: MS cache capacity (default: 500000)recycler_tablet_index_cache_capacity: Recycler cache capacity (default: 500000)tablet_index_cache_ttl_seconds: TTL in seconds (default: 0, no TTL)Integration Points
MetaService (
cloud/src/meta-service/meta_service.cpp):g_ms_cache_managerin constructorget_tablet_idx()functionRecycler (
cloud/src/recycler/util.cpp,recycler.cpp):g_recycler_cache_managerinRecycler::start()get_tablet_idx()functionrecycle_tablets()Cache Invalidation Strategy
drop_tablet/drop_index/drop_partitionif neededrecycle_tablets()Testing
Added comprehensive unit tests in
cloud/test/kv_cache_test.cpp:Performance Benefits
Release note
None
Check List (For Author)
Test
Behavior changed:
Does this need documentation?
Check List (For Reviewer who merge this PR)