[feature](fe) Add byte-weighted metadata cache framework - #66533
Open
CalvinKirs wants to merge 1 commit into
Open
[feature](fe) Add byte-weighted metadata cache framework#66533CalvinKirs wants to merge 1 commit into
CalvinKirs wants to merge 1 commit into
Conversation
Contributor
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
CalvinKirs
marked this pull request as ready for review
August 6, 2026 07:05
CalvinKirs
force-pushed
the
master-catalog-cache-memory
branch
2 times, most recently
from
August 6, 2026 08:20
7c1f1e2 to
710cdb8
Compare
### What problem does this PR solve?
Issue Number: None
Related PR: None
Problem Summary: External metadata caches are currently bounded only by entry count. Add framework support for an optional catalog-level max-weight, an entry-specific size estimator contract, mutually exclusive Caffeine size/weight construction, saturated integer weight conversion, and weighted cache statistics. Complete the framework by supporting weighted caches with synchronous removal listeners, accepting convenient binary size suffixes such as MB while retaining bare-byte compatibility, strictly rejecting malformed, negative, and overflowing max-weight values, and keeping statistics reads lightweight and side-effect free. Existing entries continue to use maximumSize unless they explicitly register an estimator and configure max-weight. Catalog-specific estimators and information_schema exposure are intentionally not included.
### Release note
None
### Check List (For Author)
- Test: Unit Test
- ./run-fe-ut.sh --run org.apache.doris.common.util.ParseUtilTest,org.apache.doris.common.CacheFactoryTest,org.apache.doris.datasource.metacache.CacheSpecTest,org.apache.doris.datasource.metacache.MetaCacheEntryTest,org.apache.doris.datasource.metacache.AbstractExternalMetaCacheTest (80 tests passed)
- DISABLE_BUILD_UI=ON ./build.sh --fe (passed, including Checkstyle)
- Behavior changed: Yes. Entries that register an estimator and configure max-weight use weighted eviction, invalid max-weight values are rejected, and statistics reads no longer trigger Caffeine maintenance.
- Does this need documentation: No
CalvinKirs
force-pushed
the
master-catalog-cache-memory
branch
from
August 6, 2026 08:50
710cdb8 to
4061bde
Compare
Member
Author
|
run buildall |
Contributor
FE UT Coverage ReportIncrement line coverage |
Contributor
TPC-H: Total hot run time: 29083 ms |
Contributor
FE Regression Coverage ReportIncrement line coverage |
Contributor
TPC-DS: Total hot run time: 166250 ms |
Contributor
ClickBench: Total hot run time: 24.76 s |
CalvinKirs
added a commit
to CalvinKirs/incubator-doris
that referenced
this pull request
Aug 7, 2026
### What problem does this PR solve? Issue Number: None Related PR: apache#66533 Problem Summary: Add opt-in JMH benchmarks for the production Hive file-listing and Iceberg partition and manifest cache estimators. The benchmarks compare the constant-time cached weight lookup, the one-time value construction and estimation cost, and JOL retained-graph traversal without adding benchmark dependencies to the default FE reactor. ### Release note None ### Check List (For Author) - Test: Manual test - `mvn -Pbenchmark -pl fe-benchmark -am test-compile -DskipTests` - Behavior changed: No - Does this need documentation: No
CalvinKirs
added a commit
to CalvinKirs/incubator-doris
that referenced
this pull request
Aug 7, 2026
### What problem does this PR solve? Issue Number: None Related PR: apache#66533 Problem Summary: Paimon's derived partition-view cache was limited only by entry count, so a catalog containing large partition views could retain substantially more FE heap than its configured entry capacity implied. Extend the generic connector metadata cache to accept a type-specific estimator, add a Paimon partition-view estimator that computes the complete immutable entry weight once when max-weight is enabled, and use the stored value for O(1) Caffeine weighing. Keep the legacy count-bounded path unchanged. Add JMH/JOL benchmarks for 10,000 and 100,000 Paimon partitions. ### Release note Paimon partition-view caches support the catalog property `meta.cache.paimon.partition_view.max-weight`. ### Check List (For Author) - Test: Unit Test - `./run-fe-ut.sh --run org.apache.doris.connector.cache.ConnectorMetadataCacheTest,org.apache.doris.connector.paimon.PaimonPartitionViewSizeEstimatorTest,org.apache.doris.connector.paimon.PaimonConnectorValidatePropertiesTest` - `mvn -Pbenchmark -pl fe-benchmark -am test-compile -DskipTests` - Behavior changed: Yes. Paimon partition-view caches can opt into byte-weighted eviction; existing capacity behavior remains the default. - Does this need documentation: No
16 tasks
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.
What problem does this PR solve?
Issue Number: None
Related PR: None
Problem Summary:
External metadata caches are currently bounded only by entry count, so entries with very different memory footprints are treated equally. This PR adds framework support for an optional catalog-level
max-weight, an entry-specific size estimator contract, mutually exclusive Caffeine size/weight construction, saturated integer weight conversion, and weighted cache statistics.It also completes the framework by supporting weighted caches with synchronous removal listeners, accepting binary size suffixes such as
512MBwhile retaining bare-byte compatibility, strictly rejecting malformed, negative, and overflowing values, and keeping statistics reads lightweight and side-effect free.Existing entries continue to use
maximumSizeunless they explicitly register an estimator and configuremax-weight. Catalog-specific Iceberg and Paimon estimators andinformation_schemaexposure are intentionally not included.What the framework does
For a cache entry that opts in, the framework asks its
MetaCacheSizeEstimatorto estimate the bytes retained by each key/value pair and passes that value to Caffeine'sWeigher. Caffeine then bounds the cache withmaximumWeightinstead ofmaximumSize. Oversized estimates are saturated to Caffeine's integer weight limit, negative estimates are rejected, and weight-based eviction also works with synchronous removal listeners.An entry opts in explicitly when its definition registers an estimator:
This keeps estimation entry-specific: the owner of each metadata type decides what its key/value pair retains. This PR does not add a generic JVM object-size utility or automatically enable weighted eviction for existing entries.
Future catalog configuration
After an engine entry registers an estimator, a catalog can select weighted eviction with the standard entry property:
max-weightaccepts binaryB,KB,MB,GB,TB, andPBsuffixes (case-insensitive); a bare integer remains bytes for compatibility. For example,512MBis parsed as512 * 1024 * 1024bytes. Malformed, negative, decimal, unknown-unit, and overflowing values are rejected. A configuredmax-weightwithout an entry estimator is also rejected.Count-bounded mode remains unchanged: omit
max-weightand configurecapacityas before.Configuration relationships
enablefalsedisables the entry cache.ttl-second0disables the cache,-1means no expiration, and a positive value enables expire-after-access.max-weightvs.capacitymax-weightis present, weighted mode is selected andcapacityis ignored; otherwise count-basedcapacityis used.0disables the cache.In short, effective enablement is
enable && ttl-second != 0 && selected-bound != 0, whereselected-boundismax-weightwhen present andcapacityotherwise.Release note
None
Check List (For Author)
Test
./run-fe-ut.sh --run org.apache.doris.common.util.ParseUtilTest,org.apache.doris.common.CacheFactoryTest,org.apache.doris.datasource.metacache.CacheSpecTest,org.apache.doris.datasource.metacache.MetaCacheEntryTest,org.apache.doris.datasource.metacache.AbstractExternalMetaCacheTest(80 tests passed)DISABLE_BUILD_UI=ON ./build.sh --fe(passed, including Checkstyle)Behavior changed:
max-weightuse weighted eviction, invalid values are rejected, and statistics reads no longer trigger Caffeine maintenance.Does this need documentation?
Check List (For Reviewer who merge this PR)