You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "fredia (via GitHub)" <gi...@apache.org> on 2025/01/02 10:41:52 UTC
[PR] [FLINK-36899][state/forst] Introduce metrics for forst cache [flink]
fredia opened a new pull request, #25884:
URL: https://github.com/apache/flink/pull/25884
<!--
*Thank you very much for contributing to Apache Flink - we are happy that you want to help us improve Flink. To help the community review your contribution in the best possible way, please go through the checklist below, which will get the contribution into a shape in which it can be best reviewed.*
*Please understand that we do not do this to make contributions to Flink a hassle. In order to uphold a high standard of quality for code contributions, while at the same time managing a large number of contributions, we need contributors to prepare the contributions well, and give reviewers enough contextual information for the review. Please also understand that contributions that do not follow this guide will take longer to review and thus typically be picked up with lower priority by the community.*
## Contribution Checklist
- Make sure that the pull request corresponds to a [JIRA issue](https://issues.apache.org/jira/projects/FLINK/issues). Exceptions are made for typos in JavaDoc or documentation files, which need no JIRA issue.
- Name the pull request in the form "[FLINK-XXXX] [component] Title of the pull request", where *FLINK-XXXX* should be replaced by the actual issue number. Skip *component* if you are unsure about which is the best component.
Typo fixes that have no associated JIRA issue should be named following this pattern: `[hotfix] [docs] Fix typo in event time introduction` or `[hotfix] [javadocs] Expand JavaDoc for PuncuatedWatermarkGenerator`.
- Fill out the template below to describe the changes contributed by the pull request. That will give reviewers the context they need to do the review.
- Make sure that the change passes the automated tests, i.e., `mvn clean verify` passes. You can set up Azure Pipelines CI to do that following [this guide](https://cwiki.apache.org/confluence/display/FLINK/Azure+Pipelines#AzurePipelines-Tutorial:SettingupAzurePipelinesforaforkoftheFlinkrepository).
- Each pull request should address only one issue, not mix up code from multiple issues.
- Each commit in the pull request has a meaningful commit message (including the JIRA id)
- Once all items of the checklist are addressed, remove the above text and this checklist, leaving only the filled out template below.
**(The sections below can be removed for hotfixes of typos)**
-->
## What is the purpose of the change
This pr introduces metrics for forst cache.
## Brief change log
- Add metrics for `FileBasedCache`.
## Verifying this change
This change added tests and can be verified as follows:
- `ForStFlinkFileSystemTest#testSstFileInCache`
## Does this pull request potentially affect one of the following parts:
- Dependencies (does it add or upgrade a dependency): (no)
- The public API, i.e., is any changed class annotated with `@Public(Evolving)`: (no)
- The serializers: (no)
- The runtime per-record code paths (performance sensitive): (no)
- Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: (no)
- The S3 file system connector: (no)
## Documentation
- Does this pull request introduce a new feature? (no)
- If yes, how is the feature documented? (not applicable / docs / JavaDocs / not documented)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-36899][state/forst] Introduce metrics for forst cache [flink]
Posted by "fredia (via GitHub)" <gi...@apache.org>.
fredia commented on code in PR #25884:
URL: https://github.com/apache/flink/pull/25884#discussion_r1908252144
##########
flink-state-backends/flink-statebackend-forst/src/main/java/org/apache/flink/state/forst/fs/cache/BundledCacheLimitPolicy.java:
##########
@@ -54,6 +56,17 @@ public void release(long toReleaseSize) {
policies.forEach(policy -> policy.release(toReleaseSize));
}
+ @Override
+ public long usedBytes() {
+ return policies.stream().mapToLong(CacheLimitPolicy::usedBytes).max().getAsLong();
+ }
+
+ @Override
+ public void registerCustomizedMetrics(String prefix, MetricGroup metricGroup) {
+ metricGroup.gauge(prefix + ".usedBytes", () -> usedBytes());
Review Comment:
👍 I moved this to the file cache.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-36899][state/forst] Introduce metrics for forst cache [flink]
Posted by "fredia (via GitHub)" <gi...@apache.org>.
fredia commented on code in PR #25884:
URL: https://github.com/apache/flink/pull/25884#discussion_r1901434127
##########
docs/content/docs/ops/metrics.md:
##########
@@ -1526,6 +1526,37 @@ Note that for failed checkpoints, metrics are updated on a best efforts basis an
### RocksDB
Certain RocksDB native metrics are available but disabled by default, you can find full documentation [here]({{< ref "docs/deployment/config" >}}#rocksdb-native-metrics)
+### ForStDB
+Certain ForStDB native metrics are available but disabled by default, you can find full documentation [here]({{< ref "docs/deployment/config" >}}#rocksdb-native-metrics)
+<table class="table table-bordered">
+ <thead>
+ <tr>
+ <th class="text-left" style="width: 18%">Scope</th>
+ <th class="text-left" style="width: 26%">Metrics</th>
+ <th class="text-left" style="width: 48%">Description</th>
+ <th class="text-left" style="width: 8%">Type</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <th rowspan="3"><strong>Task/Operator</strong></th>
+ <td>forst-cache.hit</td>
+ <td>The hit count of ForSt state backend cache.</td>
+ <td>Counter</td>
+ </tr>
+ <tr>
+ <td>forst-cache.miss</td>
+ <td>The miss count of ForSt state backend cache.</td>
+ <td>Counter</td>
+ </tr>
+ <tr>
+ <td>forst-cache.cachedBytes</td>
Review Comment:
The other metrics on this page are in camelCase, so I changed it to camelCase as well.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-36899][state/forst] Introduce metrics for forst cache [flink]
Posted by "Zakelly (via GitHub)" <gi...@apache.org>.
Zakelly commented on code in PR #25884:
URL: https://github.com/apache/flink/pull/25884#discussion_r1908112421
##########
docs/content.zh/docs/ops/metrics.md:
##########
@@ -1536,6 +1536,41 @@ Note that for failed checkpoints, metrics are updated on a best efforts basis an
### RocksDB
Certain RocksDB native metrics are available but disabled by default, you can find full documentation [here]({{< ref "docs/deployment/config" >}}#rocksdb-native-metrics)
+### ForStDB
+<table class="table table-bordered">
+ <thead>
+ <tr>
+ <th class="text-left" style="width: 18%">Scope</th>
+ <th class="text-left" style="width: 26%">Metrics</th>
+ <th class="text-left" style="width: 48%">Description</th>
+ <th class="text-left" style="width: 8%">Type</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <th rowspan="4"><strong>Task/Operator</strong></th>
+ <td>forst.fileCache.hit</td>
+ <td>The hit count of ForSt state backend cache.</td>
+ <td>Counter</td>
+ </tr>
+ <tr>
+ <td>forst.fileCache.miss</td>
+ <td>The miss count of ForSt state backend cache.</td>
+ <td>Counter</td>
+ </tr>
+ <tr>
+ <td>forst.fileCache.usedBytes</td>
+ <td>The bytes cached in ForSt state backend cache.</td>
+ <td>Gauge</td>
+ </tr>
+ <tr>
+ <td>forst.fileCache.remainingBytes</td>
+ <td>The free bytes remaining in ForSt state backend cache. Only available when space based cache is enabled. </td>
Review Comment:
```suggestion
<td>The remaining space in the volumn for the configured cache. Only available when 'state.backend.forst.cache.reserve-size' is set above 0. </td>
```
##########
flink-state-backends/flink-statebackend-forst/src/main/java/org/apache/flink/state/forst/fs/cache/BundledCacheLimitPolicy.java:
##########
@@ -54,6 +56,17 @@ public void release(long toReleaseSize) {
policies.forEach(policy -> policy.release(toReleaseSize));
}
+ @Override
+ public long usedBytes() {
+ return policies.stream().mapToLong(CacheLimitPolicy::usedBytes).max().getAsLong();
+ }
+
+ @Override
+ public void registerCustomizedMetrics(String prefix, MetricGroup metricGroup) {
+ metricGroup.gauge(prefix + ".usedBytes", () -> usedBytes());
Review Comment:
If the `BundledCacheLimitPolicy` is not enabled (only single policy is enabled), then how does this gauge report?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-36899][state/forst] Introduce metrics for forst cache [flink]
Posted by "davidradl (via GitHub)" <gi...@apache.org>.
davidradl commented on code in PR #25884:
URL: https://github.com/apache/flink/pull/25884#discussion_r1909043258
##########
flink-state-backends/flink-statebackend-forst/src/main/java/org/apache/flink/state/forst/fs/cache/FileBasedCache.java:
##########
@@ -97,6 +129,13 @@ public void delete(Path path) {
@Override
FileCacheEntry internalGet(String key, FileCacheEntry value) {
+ if (metricGroup != null) {
Review Comment:
I am curious why the key parameter is not used here?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-36899][state/forst] Introduce metrics for forst cache [flink]
Posted by "davidradl (via GitHub)" <gi...@apache.org>.
davidradl commented on code in PR #25884:
URL: https://github.com/apache/flink/pull/25884#discussion_r1909057084
##########
docs/content/docs/ops/metrics.md:
##########
@@ -1526,6 +1526,41 @@ Note that for failed checkpoints, metrics are updated on a best efforts basis an
### RocksDB
Certain RocksDB native metrics are available but disabled by default, you can find full documentation [here]({{< ref "docs/deployment/config" >}}#rocksdb-native-metrics)
+### ForStDB
+<table class="table table-bordered">
+ <thead>
+ <tr>
+ <th class="text-left" style="width: 18%">Scope</th>
+ <th class="text-left" style="width: 26%">Metrics</th>
+ <th class="text-left" style="width: 48%">Description</th>
+ <th class="text-left" style="width: 8%">Type</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <th rowspan="4"><strong>Task/Operator</strong></th>
+ <td>forst.fileCache.hit</td>
+ <td>The hit count of ForSt state backend cache.</td>
Review Comment:
I am curious.
Do the cache entries get invalidated at any time , due to size or time? Is this something we can capture in the metrics? I assume a miss will result in the value being added to the cache.
It would be useful to include in the documentation how to interpret the hit and miss counts and when they indicate that something needs to be changed / tuned.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-36899][state/forst] Introduce metrics for forst cache [flink]
Posted by "davidradl (via GitHub)" <gi...@apache.org>.
davidradl commented on code in PR #25884:
URL: https://github.com/apache/flink/pull/25884#discussion_r1909057084
##########
docs/content/docs/ops/metrics.md:
##########
@@ -1526,6 +1526,41 @@ Note that for failed checkpoints, metrics are updated on a best efforts basis an
### RocksDB
Certain RocksDB native metrics are available but disabled by default, you can find full documentation [here]({{< ref "docs/deployment/config" >}}#rocksdb-native-metrics)
+### ForStDB
+<table class="table table-bordered">
+ <thead>
+ <tr>
+ <th class="text-left" style="width: 18%">Scope</th>
+ <th class="text-left" style="width: 26%">Metrics</th>
+ <th class="text-left" style="width: 48%">Description</th>
+ <th class="text-left" style="width: 8%">Type</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <th rowspan="4"><strong>Task/Operator</strong></th>
+ <td>forst.fileCache.hit</td>
+ <td>The hit count of ForSt state backend cache.</td>
Review Comment:
I am curious.
Do the cache entries get invalidated at any time , due to size or time? Is this something we can capture in the metrics? I assume a miss will result in the value being added to the cache.
It would be useful to include in the documentation how to interpret the hit and miss counts and when they indicate that something needs to be changed / tuned.
Can the counters be reset - would this be useful?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-36899][state/forst] Introduce metrics for forst cache [flink]
Posted by "flinkbot (via GitHub)" <gi...@apache.org>.
flinkbot commented on PR #25884:
URL: https://github.com/apache/flink/pull/25884#issuecomment-2567579868
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "3c65a9c81e399d9d92ad993d9bd5b086265ccf32",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "3c65a9c81e399d9d92ad993d9bd5b086265ccf32",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 3c65a9c81e399d9d92ad993d9bd5b086265ccf32 UNKNOWN
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run azure` re-run the last Azure build
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-36899][state/forst] Introduce metrics for forst cache [flink]
Posted by "fredia (via GitHub)" <gi...@apache.org>.
fredia commented on PR #25884:
URL: https://github.com/apache/flink/pull/25884#issuecomment-2586100632
@flinkbot run azure
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-36899][state/forst] Introduce metrics for forst cache [flink]
Posted by "Zakelly (via GitHub)" <gi...@apache.org>.
Zakelly commented on code in PR #25884:
URL: https://github.com/apache/flink/pull/25884#discussion_r1905093224
##########
flink-state-backends/flink-statebackend-forst/src/test/java/org/apache/flink/state/forst/fs/ForStFlinkFileSystemTest.java:
##########
@@ -247,6 +273,9 @@ void testSstFileInCache() throws IOException {
.isTrue();
assertThat(fileSystem.exists(new org.apache.flink.core.fs.Path(cachePath, "1.sst")))
.isTrue();
+ assertThat(registeredGauges.get("forst-cache.cachedBytes").getValue()).isEqualTo(234L);
+ assertThat(registeredCounters.get("forst-cache.hit").getCount()).isEqualTo(0L);
+ assertThat(registeredCounters.get("forst-cache.miss").getCount()).isEqualTo(0L);
FileCacheEntry cacheEntry = cache.get(cachePath.getPath() + "/1.sst");
Review Comment:
also rename those to `forst.fileCache` ?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-36899][state/forst] Introduce metrics for forst cache [flink]
Posted by "fredia (via GitHub)" <gi...@apache.org>.
fredia commented on code in PR #25884:
URL: https://github.com/apache/flink/pull/25884#discussion_r1909974038
##########
flink-state-backends/flink-statebackend-forst/src/main/java/org/apache/flink/state/forst/fs/cache/FileBasedCache.java:
##########
@@ -97,6 +129,13 @@ public void delete(Path path) {
@Override
FileCacheEntry internalGet(String key, FileCacheEntry value) {
+ if (metricGroup != null) {
Review Comment:
`Key` is reserved for future use.
`internalGet` is used for some customized operations like statistics.
This PR only focuses on the `hit`, `miss` metric which is not related with `key`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-36899][state/forst] Introduce metrics for forst cache [flink]
Posted by "davidradl (via GitHub)" <gi...@apache.org>.
davidradl commented on code in PR #25884:
URL: https://github.com/apache/flink/pull/25884#discussion_r1910600361
##########
docs/content/docs/ops/metrics.md:
##########
@@ -1526,6 +1526,41 @@ Note that for failed checkpoints, metrics are updated on a best efforts basis an
### RocksDB
Certain RocksDB native metrics are available but disabled by default, you can find full documentation [here]({{< ref "docs/deployment/config" >}}#rocksdb-native-metrics)
+### ForStDB
+<table class="table table-bordered">
+ <thead>
+ <tr>
+ <th class="text-left" style="width: 18%">Scope</th>
+ <th class="text-left" style="width: 26%">Metrics</th>
+ <th class="text-left" style="width: 48%">Description</th>
+ <th class="text-left" style="width: 8%">Type</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <th rowspan="4"><strong>Task/Operator</strong></th>
+ <td>forst.fileCache.hit</td>
+ <td>The hit count of ForSt state backend cache.</td>
Review Comment:
> > Do the cache entries get invalidated at any time , due to size or time?
>
> Yes.
>
> > Is this something we can capture in the metrics?
>
> Something means what? could you give an example?
>
> > Can the counters be reset - would this be useful?
>
> The counter can not be reset while the job is running, this counter is a common counter defined in Flink, if you want to make the counter resettable, a discussion may need to be started.
@fredia thanks for your reply. Sorry for the bassc questions. I am not sure how the invalidation occurs - can you count the number of invalidations in a similar way to the hits and misses.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-36899][state/forst] Introduce metrics for forst cache [flink]
Posted by "Zakelly (via GitHub)" <gi...@apache.org>.
Zakelly commented on code in PR #25884:
URL: https://github.com/apache/flink/pull/25884#discussion_r1900800573
##########
flink-state-backends/flink-statebackend-forst/src/main/java/org/apache/flink/state/forst/ForStResourceContainer.java:
##########
@@ -120,21 +121,24 @@ public final class ForStResourceContainer implements AutoCloseable {
@Nullable private java.nio.file.Path relocatedDbLogBaseDir;
+ /** The metric group for reporting metrics. */
+ @Nullable private MetricGroup metricGroup;
Review Comment:
Could be `final`
##########
docs/content/docs/ops/metrics.md:
##########
@@ -1526,6 +1526,37 @@ Note that for failed checkpoints, metrics are updated on a best efforts basis an
### RocksDB
Certain RocksDB native metrics are available but disabled by default, you can find full documentation [here]({{< ref "docs/deployment/config" >}}#rocksdb-native-metrics)
+### ForStDB
+Certain ForStDB native metrics are available but disabled by default, you can find full documentation [here]({{< ref "docs/deployment/config" >}}#rocksdb-native-metrics)
+<table class="table table-bordered">
+ <thead>
+ <tr>
+ <th class="text-left" style="width: 18%">Scope</th>
+ <th class="text-left" style="width: 26%">Metrics</th>
+ <th class="text-left" style="width: 48%">Description</th>
+ <th class="text-left" style="width: 8%">Type</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <th rowspan="3"><strong>Task/Operator</strong></th>
+ <td>forst-cache.hit</td>
Review Comment:
I suggest we use `forst` as a single metric group name? like `rocksdb` does
```suggestion
<td>forst.file-cache.hit</td>
```
##########
docs/content.zh/docs/ops/metrics.md:
##########
@@ -1536,6 +1536,37 @@ Note that for failed checkpoints, metrics are updated on a best efforts basis an
### RocksDB
Certain RocksDB native metrics are available but disabled by default, you can find full documentation [here]({{< ref "docs/deployment/config" >}}#rocksdb-native-metrics)
+### ForStDB
+Certain ForStDB native metrics are available but disabled by default, you can find full documentation [here]({{< ref "docs/deployment/config" >}}#rocksdb-native-metrics)
Review Comment:
Remove this? Since we don't have the mentioned full documentation.
##########
docs/content/docs/ops/metrics.md:
##########
@@ -1526,6 +1526,37 @@ Note that for failed checkpoints, metrics are updated on a best efforts basis an
### RocksDB
Certain RocksDB native metrics are available but disabled by default, you can find full documentation [here]({{< ref "docs/deployment/config" >}}#rocksdb-native-metrics)
+### ForStDB
+Certain ForStDB native metrics are available but disabled by default, you can find full documentation [here]({{< ref "docs/deployment/config" >}}#rocksdb-native-metrics)
+<table class="table table-bordered">
+ <thead>
+ <tr>
+ <th class="text-left" style="width: 18%">Scope</th>
+ <th class="text-left" style="width: 26%">Metrics</th>
+ <th class="text-left" style="width: 48%">Description</th>
+ <th class="text-left" style="width: 8%">Type</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <th rowspan="3"><strong>Task/Operator</strong></th>
+ <td>forst-cache.hit</td>
+ <td>The hit count of ForSt state backend cache.</td>
+ <td>Counter</td>
+ </tr>
+ <tr>
+ <td>forst-cache.miss</td>
+ <td>The miss count of ForSt state backend cache.</td>
+ <td>Counter</td>
+ </tr>
+ <tr>
+ <td>forst-cache.cachedBytes</td>
Review Comment:
We'd better unify the naming style, using kebab-case instead.
```suggestion
<td>forst.file-cache.used-bytes</td>
```
##########
flink-state-backends/flink-statebackend-forst/src/main/java/org/apache/flink/state/forst/fs/cache/FileBasedCache.java:
##########
@@ -46,12 +52,37 @@ public class FileBasedCache extends LruCache<String, FileCacheEntry> {
/** Whether the cache is closed. */
private volatile boolean closed;
+ private MetricGroup metricGroup;
+
+ /** Hit metric. */
+ private transient Counter hitCounter;
+
+ /** Miss metric. */
+ private transient Counter missCounter;
+
+ /** Cached bytes metric. */
+ private transient Gauge<Long> cachedBytesGauge;
+
public FileBasedCache(
- int capacity, CacheLimitPolicy cacheLimitPolicy, FileSystem cacheFs, Path basePath) {
+ int capacity,
+ CacheLimitPolicy cacheLimitPolicy,
+ FileSystem cacheFs,
+ Path basePath,
+ MetricGroup metricGroup) {
super(capacity, cacheLimitPolicy);
this.closed = false;
this.cacheFs = cacheFs;
this.basePath = basePath;
+ if (metricGroup != null) {
+ this.metricGroup = metricGroup;
+ this.hitCounter =
+ metricGroup.counter(FORST_CACHE + ".hit", new ThreadSafeSimpleCounter());
+ this.missCounter =
+ metricGroup.counter(FORST_CACHE + ".miss", new ThreadSafeSimpleCounter());
+ this.cachedBytesGauge =
+ metricGroup.gauge(
+ FORST_CACHE + ".cachedBytes", () -> cacheLimitPolicy.cachedBytes());
Review Comment:
Besides this, each policy may have its' own metrics. e.g. The `SpaceBasedCacheLimitPolicy` may need report the remaining space.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-36899][state/forst] Introduce metrics for forst cache [flink]
Posted by "fredia (via GitHub)" <gi...@apache.org>.
fredia commented on code in PR #25884:
URL: https://github.com/apache/flink/pull/25884#discussion_r1912767509
##########
docs/content/docs/ops/metrics.md:
##########
@@ -1526,6 +1526,41 @@ Note that for failed checkpoints, metrics are updated on a best efforts basis an
### RocksDB
Certain RocksDB native metrics are available but disabled by default, you can find full documentation [here]({{< ref "docs/deployment/config" >}}#rocksdb-native-metrics)
+### ForStDB
+<table class="table table-bordered">
+ <thead>
+ <tr>
+ <th class="text-left" style="width: 18%">Scope</th>
+ <th class="text-left" style="width: 26%">Metrics</th>
+ <th class="text-left" style="width: 48%">Description</th>
+ <th class="text-left" style="width: 8%">Type</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <th rowspan="4"><strong>Task/Operator</strong></th>
+ <td>forst.fileCache.hit</td>
+ <td>The hit count of ForSt state backend cache.</td>
Review Comment:
> I am not sure how the invalidation occurs - can you count the number of invalidations in a similar way to the hits and misses.
I think "invalidations" == "misses" for a cache. Take a fixed-sized FIFO cache as example, when the requested data is not found in the cache, a "miss(or invalidations )" happens. Due to limited size of the cache, if the cache is full and new data needs to be added, the oldest data (first-in) will be replaced. If this removed data is needed again later, it results in a miss.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-36899][state/forst] Introduce metrics for forst cache [flink]
Posted by "fredia (via GitHub)" <gi...@apache.org>.
fredia merged PR #25884:
URL: https://github.com/apache/flink/pull/25884
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-36899][state/forst] Introduce metrics for forst cache [flink]
Posted by "fredia (via GitHub)" <gi...@apache.org>.
fredia commented on code in PR #25884:
URL: https://github.com/apache/flink/pull/25884#discussion_r1909979879
##########
flink-state-backends/flink-statebackend-forst/src/main/java/org/apache/flink/state/forst/fs/ForStFlinkFileSystem.java:
##########
@@ -119,7 +121,11 @@ public static FileBasedCache getFileBasedCache(
new File(cacheBase.toString()), cacheReservedSize, SST_FILE_SIZE);
}
return new FileBasedCache(
- Integer.MAX_VALUE, cacheLimitPolicy, cacheBase.getFileSystem(), cacheBase);
+ Integer.MAX_VALUE,
+ cacheLimitPolicy,
+ cacheBase.getFileSystem(),
Review Comment:
`cacheBase.getFileSystem()` can throw IOException.
If we get fileSystem in `FileBasedCache` constructor, the constructor would throw IOException, this is something I don't want to introduce.
So, I prefer to keep ` cacheBase.getFileSystem()` in parameter.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-36899][state/forst] Introduce metrics for forst cache [flink]
Posted by "davidradl (via GitHub)" <gi...@apache.org>.
davidradl commented on PR #25884:
URL: https://github.com/apache/flink/pull/25884#issuecomment-2583120995
Reviewed by Chi on 09/01/2025 Go back to the submitter with review comments.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-36899][state/forst] Introduce metrics for forst cache [flink]
Posted by "fredia (via GitHub)" <gi...@apache.org>.
fredia commented on code in PR #25884:
URL: https://github.com/apache/flink/pull/25884#discussion_r1909979879
##########
flink-state-backends/flink-statebackend-forst/src/main/java/org/apache/flink/state/forst/fs/ForStFlinkFileSystem.java:
##########
@@ -119,7 +121,11 @@ public static FileBasedCache getFileBasedCache(
new File(cacheBase.toString()), cacheReservedSize, SST_FILE_SIZE);
}
return new FileBasedCache(
- Integer.MAX_VALUE, cacheLimitPolicy, cacheBase.getFileSystem(), cacheBase);
+ Integer.MAX_VALUE,
+ cacheLimitPolicy,
+ cacheBase.getFileSystem(),
Review Comment:
I will remove `cacheBase.getFileSystem()`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-36899][state/forst] Introduce metrics for forst cache [flink]
Posted by "fredia (via GitHub)" <gi...@apache.org>.
fredia commented on code in PR #25884:
URL: https://github.com/apache/flink/pull/25884#discussion_r1909985766
##########
docs/content/docs/ops/metrics.md:
##########
@@ -1526,6 +1526,41 @@ Note that for failed checkpoints, metrics are updated on a best efforts basis an
### RocksDB
Certain RocksDB native metrics are available but disabled by default, you can find full documentation [here]({{< ref "docs/deployment/config" >}}#rocksdb-native-metrics)
+### ForStDB
+<table class="table table-bordered">
+ <thead>
+ <tr>
+ <th class="text-left" style="width: 18%">Scope</th>
+ <th class="text-left" style="width: 26%">Metrics</th>
+ <th class="text-left" style="width: 48%">Description</th>
+ <th class="text-left" style="width: 8%">Type</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <th rowspan="4"><strong>Task/Operator</strong></th>
+ <td>forst.fileCache.hit</td>
+ <td>The hit count of ForSt state backend cache.</td>
Review Comment:
> Do the cache entries get invalidated at any time , due to size or time?
Yes.
> Is this something we can capture in the metrics?
Something means what? could you give an example?
> Can the counters be reset - would this be useful?
The counter can not be reset while the job is running, this counter is a common counter defined in Flink, if you want to make the counter resettable, a discussion may need to be started.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-36899][state/forst] Introduce metrics for forst cache [flink]
Posted by "davidradl (via GitHub)" <gi...@apache.org>.
davidradl commented on code in PR #25884:
URL: https://github.com/apache/flink/pull/25884#discussion_r1909046749
##########
flink-state-backends/flink-statebackend-forst/src/main/java/org/apache/flink/state/forst/fs/ForStFlinkFileSystem.java:
##########
@@ -119,7 +121,11 @@ public static FileBasedCache getFileBasedCache(
new File(cacheBase.toString()), cacheReservedSize, SST_FILE_SIZE);
}
return new FileBasedCache(
- Integer.MAX_VALUE, cacheLimitPolicy, cacheBase.getFileSystem(), cacheBase);
+ Integer.MAX_VALUE,
+ cacheLimitPolicy,
+ cacheBase.getFileSystem(),
Review Comment:
do we need to pass cacheBase.getFileSystem() when we already pass cacheBase?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org