feat(compact): Support global LookupFileCache for compact lookup mode#220
Merged
lszskye merged 11 commits intoalibaba:mainfrom Apr 14, 2026
Merged
feat(compact): Support global LookupFileCache for compact lookup mode#220lszskye merged 11 commits intoalibaba:mainfrom
lszskye merged 11 commits intoalibaba:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR introduces a global, shared LookupFileCache for compact lookup mode using a new generic LRU cache, enabling disk-size-based eviction and time-based expiration of locally cached lookup files.
Changes:
- Added
GenericLruCachewith weight-based eviction, expiration, and removal callbacks; refactored blockLruCacheto delegate to it. - Implemented a global
LookupFileCacheintegration inLookupLevelsandMergeTreeCompactManagerFactory, including per-instance cleanup tracking. - Added new CoreOptions/Options (
lookup.cache-file-retention,lookup.cache-max-disk-size) and extensive UT/IT coverage for caching behavior.
Reviewed changes
Copilot reviewed 24 out of 24 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| test/inte/pk_compaction_inte_test.cpp | Adds an integration test covering DV + aggregation with injected I/O errors. |
| src/paimon/core/mergetree/lookup_levels_test.cpp | Updates tests for shared cache API and adds cache integration/eviction/expiration coverage. |
| src/paimon/core/mergetree/lookup_levels.h | Switches per-instance map cache to shared global cache + ownership tracking; adds Close/dtor. |
| src/paimon/core/mergetree/lookup_levels.cpp | Implements shared cache usage, weight capture, ownership tracking, and per-instance cleanup. |
| src/paimon/core/mergetree/lookup_file_test.cpp | Extends LookupFile tests to validate cache lifecycle and file deletion on eviction. |
| src/paimon/core/mergetree/lookup_file.h | Adds LookupFileCache type alias, cache factory, weight/removal callbacks, and per-file callback. |
| src/paimon/core/mergetree/lookup/remote_lookup_file_manager_test.cpp | Updates helper creation to pass the new lookup file cache into LookupLevels. |
| src/paimon/core/mergetree/lookup/remote_lookup_file_manager.cpp | Propagates AddLocalFile status handling. |
| src/paimon/core/mergetree/compact/merge_tree_compact_manager_factory.h | Introduces factory-owned global lookup_file_cache_ and invalidates it on Close. |
| src/paimon/core/mergetree/compact/merge_tree_compact_manager_factory.cpp | Lazily creates and wires the global cache into lookup-based rewriters. |
| src/paimon/core/mergetree/compact/lookup_merge_tree_compact_rewriter_test.cpp | Updates tests to construct and pass LookupFileCache. |
| src/paimon/core/core_options_test.cpp | Adds coverage for new lookup cache retention/max-disk options parsing/defaults. |
| src/paimon/core/core_options.h | Adds getters for lookup cache retention and max disk size. |
| src/paimon/core/core_options.cpp | Implements parsing/storage of retention/max-disk options. |
| src/paimon/common/utils/generic_lru_cache_test.cpp | Adds comprehensive tests for eviction, expiration, callbacks, and concurrency. |
| src/paimon/common/utils/generic_lru_cache.h | Adds the new generic LRU cache implementation. |
| src/paimon/common/memory/memory_segment.h | Adds operator== used by generic cache equality helpers for pointer values. |
| src/paimon/common/io/cache/lru_cache_test.cpp | Updates tests to assert Put() status after signature change. |
| src/paimon/common/io/cache/lru_cache.h | Refactors block cache to wrap GenericLruCache and changes Put() to return Status. |
| src/paimon/common/io/cache/lru_cache.cpp | Implements LruCache as a thin wrapper over GenericLruCache. |
| src/paimon/common/io/cache/cache.h | Updates Cache::Put() to return Status and adds CacheValue::operator==. |
| src/paimon/common/defs.cpp | Defines new option string constants. |
| src/paimon/CMakeLists.txt | Registers the new generic LRU cache test target. |
| include/paimon/defs.h | Exposes new public option constants for retention and max disk size. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
ddb04d3 to
4d2df59
Compare
lszskye
reviewed
Apr 13, 2026
lszskye
reviewed
Apr 13, 2026
lszskye
reviewed
Apr 13, 2026
lszskye
reviewed
Apr 13, 2026
lszskye
reviewed
Apr 13, 2026
lszskye
reviewed
Apr 13, 2026
lucasfang
reviewed
Apr 14, 2026
lszskye
approved these changes
Apr 14, 2026
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.
Purpose
Linked issue: #93
Introduce a global
LookupFileCachebased on a new generic LRU cache (GenericLruCache) to manage lookup files acrossLookupLevelsinstances in compact lookup mode. This enables:lookup.cache-max-disk-size(default: unlimited).lookup.cache-file-retention(default: 1 hour). Expired files are re-read from DFS on next access.LookupLevelsinstances share a singleLookupFileCacheowned byMergeTreeCompactManagerFactory, with each instance tracking its own cached files for proper cleanup on close.LruCache: The existing block-levelLruCacheis refactored to delegate toGenericLruCache, eliminating duplicated LRU logic.CoreOptionsTests
API and Format
include/paimon/defs.h: Added two new option constants:Options::LOOKUP_CACHE_FILE_RETENTION("lookup.cache-file-retention")Options::LOOKUP_CACHE_MAX_DISK_SIZE("lookup.cache-max-disk-size")Documentation
Generative AI tooling
Generated-by: Aone Copilot (Claude claude4.6)