Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[core] Introduce CacheStats and expose ScanStats #4678

Merged
merged 2 commits into from
Dec 18, 2024

Conversation

mxdzs0612
Copy link
Contributor

@mxdzs0612 mxdzs0612 commented Dec 10, 2024

Purpose

Linked issue: close #xxx

Add CacheSizes for CachingCatalog and CacheMetrics for ObjectCache so that engine can get cache stats at query level.

Tests

added

API and Format

CachingCatalog.estimatedCacheSizes
ScanMetrics.getLatestScan
ScanMetrics.getCacheMetrics

Documentation

added

@mxdzs0612 mxdzs0612 changed the title (Preview)[core] Introduce CacheStats and expose ScanStats [core] Introduce CacheStats and expose ScanStats Dec 13, 2024
@mxdzs0612 mxdzs0612 marked this pull request as ready for review December 13, 2024 02:35
@mxdzs0612
Copy link
Contributor Author

@JingsongLi Ready for review now, PTAL, thx~

public class CatalogCacheStats {
private long databaseCacheSize;
private long tableCacheSize;
private long manifestCacheSize;
Copy link
Contributor

Choose a reason for hiding this comment

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

What it means? Memory size or something else?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Size. I added a new long value to evaluate bytes in mem.

@@ -305,6 +316,23 @@ public void invalidateTable(Identifier identifier) {
}
}

public CatalogCacheStats getCatalogCacheStats() {
Copy link
Contributor

Choose a reason for hiding this comment

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

where call this method?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's for other engine to see these stats when selecting a Paimon table.

this.databaseCacheSize = databaseCacheSize;
}

public long getTableCacheSize() {
Copy link
Contributor

Choose a reason for hiding this comment

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

where call these four getXXX method?

this.missedObject = new AtomicLong(0);
}

public AtomicLong getHitObject() {
Copy link
Contributor

Choose a reason for hiding this comment

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

when call this method?

public static final ConfigOption<Boolean> CACHE_STATS_ENABLED =
key("cache.cache-stats-enabled")
.booleanType()
.defaultValue(false)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why default value is false?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Don't want to affect other engines who do not need this metrics. You think true is better?

@mxdzs0612 mxdzs0612 force-pushed the CacheStats branch 2 times, most recently from b180968 to ca1cf74 Compare December 17, 2024 02:35
}

public void reportScan(ScanStats scanStats) {
latestScan = scanStats;
durationHistogram.update(scanStats.getDuration());
}

public void reportCache(CacheMetrics cacheMetrics) {
this.cacheMetrics = cacheMetrics;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why set cacheMetrics again? You should use this cacheMetrics...

Copy link
Contributor Author

@mxdzs0612 mxdzs0612 Dec 18, 2024

Choose a reason for hiding this comment

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

Just want to make the code unified....

@JingsongLi
Copy link
Contributor

+1

@JingsongLi JingsongLi merged commit 32da035 into apache:master Dec 18, 2024
13 checks passed
@mxdzs0612 mxdzs0612 deleted the CacheStats branch December 18, 2024 02:51
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.

3 participants