You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "masteryhx (via GitHub)" <gi...@apache.org> on 2023/09/12 11:18:30 UTC

[GitHub] [flink] masteryhx opened a new pull request, #22800: [FLINK-23411][checkpoint] Expose Checkpoint metrics in task level

masteryhx opened a new pull request, #22800:
URL: https://github.com/apache/flink/pull/22800

   <!--
   *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
   
    - Expose task level checkpoint metircs that just like what shows in Flink UI.
   
   
   ## Brief change log
   
   - Introduce AsyncCheckpointMetricsGroup to tracker CheckpointMetrics related to async phase
   - Make subtask checkpoint coordinator register and report CheckpointMetrics
   - Expose more sync metrics in InputProcessorUtil
   
   
   ## Verifying this change
   
   
   This change added tests and can be verified as follows:
   
   - Add AsyncCheckpointMetricsGroupTest to test AsyncCheckpointMetricsGroup
   - Add more cases in SourceStreamTaskTestBase
   
   ## 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? no
   


-- 
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-23411][checkpoint] Expose Checkpoint metrics in task level [flink]

Posted by "pnowojski (via GitHub)" <gi...@apache.org>.
pnowojski commented on PR #22800:
URL: https://github.com/apache/flink/pull/22800#issuecomment-1790961699

   I'm closing that as I will be publishing a FLIP counter-proposal that uses tracing to achieve the same goal.


-- 
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


[GitHub] [flink] pnowojski commented on a diff in pull request #22800: [FLINK-23411][checkpoint] Expose Checkpoint metrics in task level

Posted by "pnowojski (via GitHub)" <gi...@apache.org>.
pnowojski commented on code in PR #22800:
URL: https://github.com/apache/flink/pull/22800#discussion_r1322777799


##########
flink-runtime/src/main/java/org/apache/flink/runtime/checkpoint/AsyncCheckpointMetricsGroup.java:
##########
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.runtime.checkpoint;
+
+import org.apache.flink.annotation.VisibleForTesting;
+import org.apache.flink.metrics.MetricGroup;
+import org.apache.flink.runtime.metrics.groups.ProxyMetricGroup;
+
+import javax.annotation.Nonnull;
+
+/** A metric group for {@link CheckpointMetrics} related to the async phase. */
+public class AsyncCheckpointMetricsGroup extends ProxyMetricGroup<MetricGroup> {
+
+    private volatile CheckpointMetrics checkpointMetrics;
+
+    public AsyncCheckpointMetricsGroup(MetricGroup parent) {
+        super(parent);
+        this.checkpointMetrics = new CheckpointMetrics();
+        registerMetrics();
+    }
+
+    @VisibleForTesting
+    public static final String BYTES_PERSISTED_DURING_ALIGNMENT =
+            "checkpointBytesPersistedDuringAlignment";
+
+    @VisibleForTesting
+    public static final String ASYNC_DURATION_MILLIS = "checkpointAsyncDurationMillis";
+
+    @VisibleForTesting
+    public static final String BYTES_PERSISTED_OF_THIS_CHECKPOINT =
+            "checkpointBytesPersistedOfThisCheckpoint";
+
+    @VisibleForTesting
+    public static final String TOTAL_BYTES_PERSISTED = "checkpointTotalBytesPersisted";

Review Comment:
   Could you explain why this is added here and not in the `MetricNames`?



##########
docs/content.zh/docs/ops/metrics.md:
##########
@@ -1348,16 +1348,46 @@ Note that for failed checkpoints, metrics are updated on a best efforts basis an
       <td>Gauge</td>
     </tr>
     <tr>
-      <th rowspan="2"><strong>Task</strong></th>
+      <th rowspan="8"><strong>Task/Operator</strong></th>
       <td>checkpointAlignmentTime</td>
-      <td>The time in nanoseconds that the last barrier alignment took to complete, or how long the current alignment has taken so far (in nanoseconds). This is the time between receiving first and the last checkpoint barrier. You can find more information in the [Monitoring State and Checkpoints section]({{< ref "docs/ops/state/large_state_tuning" >}}#monitoring-state-and-checkpoints)</td>
+      <td>The time in nanoseconds that the last barrier alignment took to complete, or how long the current alignment has taken so far (in nanoseconds). This is the time between receiving first and the last checkpoint barrier. You can find more information in the <a href="docs/ops/state/large_state_tuning">#monitoring-state-and-checkpoints">Monitoring State and Checkpoints section</a>.</td>
       <td>Gauge</td>
     </tr>
     <tr>
       <td>checkpointStartDelayNanos</td>
       <td>The time in nanoseconds that elapsed between the creation of the last checkpoint and the time when the checkpointing process has started by this Task. This delay shows how long it takes for the first checkpoint barrier to reach the task. A high value indicates back-pressure. If only a specific task has a long start delay, the most likely reason is data skew.</td>
       <td>Gauge</td>
     </tr>
+    <tr>
+      <td>checkpointBytesProcessedDuringAlignment</td>
+      <td>The approximate number of bytes processed during the alignment (time between receiving the first and the last checkpoint barrier) over all acknowledged subtasks.</td>
+      <td>Gauge</td>
+    </tr>
+    <tr>
+      <td>checkpointBytesPersistedDuringAlignment</td>
+      <td>The approximate number of bytes persisted during the alignment (time between receiving the first and the last checkpoint barrier) over all acknowledged subtasks. It could be larger than zero only if the unaligned checkpoints are enabled.</td>
+      <td>Gauge</td>
+    </tr>
+    <tr>
+      <td>checkpointSyncDurationMillis</td>
+      <td>The duration of the synchronous part of the checkpoint. This includes snapshotting state of the operators and blocks all other activity on the subtask (processing records, firing timers, etc).</td>
+      <td>Gauge</td>
+    </tr>
+    <tr>
+      <td>checkpointAsyncDurationMillis</td>
+      <td>The duration of the asynchronous part of the checkpoint. This includes time it took to write the checkpoint on to the selected filesystem. For unaligned checkpoints this also includes also the time the subtask had to wait for last of the checkpoint barriers to arrive (alignment duration) and the time it took to persist the in-flight data.</td>
+      <td>Gauge</td>
+    </tr>
+    <tr>
+      <td>checkpointBytesPersistedOfThisCheckpoint</td>
+      <td>The persisted data size during the sync and async phases of that checkpoint, the value could be different from totalBytesPersisted if incremental checkpoint or changelog is enabled.</td>
+      <td>Gauge</td>
+    </tr>
+    <tr>
+      <td>checkpointTotalBytesPersisted</td>
+      <td>The total persisted data size of that checkpoint.</td>
+      <td>Gauge</td>
+    </tr>

Review Comment:
   I think all of those metrics should be prefixed `last`.



##########
flink-streaming-java/src/main/java/org/apache/flink/streaming/runtime/io/checkpointing/CheckpointBarrierHandler.java:
##########
@@ -118,6 +125,18 @@ public long getCheckpointStartDelayNanos() {
         return latestCheckpointStartDelayNanos;
     }
 
+    public long getBytesProcessedDuringAlignment() {
+        if (isDuringAlignment()) {
+            return bytesProcessedDuringAlignment;
+        } else {
+            return FutureUtils.getOrDefault(latestBytesProcessedDuringAlignment, 0L);
+        }
+    }
+
+    public long getCheckpointSyncDurationMillis() {

Review Comment:
   Both of those metrics are untested as far as I can tell.



##########
flink-streaming-java/src/main/java/org/apache/flink/streaming/runtime/io/checkpointing/CheckpointBarrierHandler.java:
##########
@@ -118,6 +125,18 @@ public long getCheckpointStartDelayNanos() {
         return latestCheckpointStartDelayNanos;
     }
 
+    public long getBytesProcessedDuringAlignment() {
+        if (isDuringAlignment()) {
+            return bytesProcessedDuringAlignment;
+        } else {
+            return FutureUtils.getOrDefault(latestBytesProcessedDuringAlignment, 0L);
+        }
+    }
+
+    public long getCheckpointSyncDurationMillis() {
+        return latestCheckpointSyncDurationMillis;

Review Comment:
   nit: rename both field and getter to `last/getLastCheckpointSyncDurationMillis`?



##########
flink-runtime/src/test/java/org/apache/flink/runtime/checkpoint/AsyncCheckpointMetricsGroupTest.java:
##########
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.runtime.checkpoint;
+
+import org.apache.flink.metrics.Gauge;
+import org.apache.flink.metrics.MetricGroup;
+import org.apache.flink.metrics.groups.UnregisteredMetricsGroup;
+
+import org.junit.jupiter.api.Test;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/** Tests for the {@link AsyncCheckpointMetricsGroup} class. */
+public class AsyncCheckpointMetricsGroupTest {
+
+    @Test
+    public void testCheckpointMetricsRegistration() {
+        // Construct a CheckpointMetricsGroup.
+        final Map<String, Gauge<?>> registeredGauges = new HashMap<>();
+        MetricGroup metricGroup =
+                new UnregisteredMetricsGroup() {
+                    @Override
+                    public <T, G extends Gauge<T>> G gauge(String name, G gauge) {
+                        registeredGauges.put(name, gauge);
+                        return gauge;
+                    }
+                };
+        AsyncCheckpointMetricsGroup asyncCheckpointMetricsGroup =
+                new AsyncCheckpointMetricsGroup(metricGroup);
+
+        // Construct a CheckpointMetrics.
+        CheckpointMetrics checkpointMetrics =
+                new CheckpointMetricsBuilder()
+                        .setBytesProcessedDuringAlignment(12L)
+                        .setAlignmentDurationNanos(23L)
+                        .setBytesPersistedOfThisCheckpoint(34L)
+                        .setTotalBytesPersisted(45L)
+                        .setAsyncDurationMillis(56L)
+                        .setSyncDurationMillis(67L)
+                        .setCheckpointStartDelayNanos(78L)
+                        .build();
+
+        // Update and Verify the status of AsyncCheckpointMetricsGroup.
+        asyncCheckpointMetricsGroup.reportCheckpointMetrics(checkpointMetrics);
+        assertThat(

Review Comment:
   This test doesn't fully cover newly added code. For example one might remove `asyncCheckpointMetricsGroup.reportCheckpointMetrics()` call from the `AsyncCheckpointRunnable` and this test would be still passing.
   
   To have full test coverage I think you should try to write a metrics reporting test in `SubtaskCheckpointCoordinatorTest`.
   



-- 
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


[GitHub] [flink] flinkbot commented on pull request #22800: [FLINK-23411][checkpoint] Expose Checkpoint metrics in task level

Posted by "flinkbot (via GitHub)" <gi...@apache.org>.
flinkbot commented on PR #22800:
URL: https://github.com/apache/flink/pull/22800#issuecomment-1594051566

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "772dc5ca7bc2df3bab66e82fc0477013dca1dfc7",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "772dc5ca7bc2df3bab66e82fc0477013dca1dfc7",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 772dc5ca7bc2df3bab66e82fc0477013dca1dfc7 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


[GitHub] [flink] rkhachatryan closed pull request #22800: [FLINK-23411][checkpoint] Expose Checkpoint metrics in task level

Posted by "rkhachatryan (via GitHub)" <gi...@apache.org>.
rkhachatryan closed pull request #22800: [FLINK-23411][checkpoint] Expose Checkpoint metrics in task level
URL: https://github.com/apache/flink/pull/22800


-- 
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


[GitHub] [flink] masteryhx commented on pull request #22800: [FLINK-23411][checkpoint] Expose Checkpoint metrics in task level

Posted by "masteryhx (via GitHub)" <gi...@apache.org>.
masteryhx commented on PR #22800:
URL: https://github.com/apache/flink/pull/22800#issuecomment-1605922243

   @rkhachatryan @StefanRRichter @reswqa 
   Could you help to take a review ? 
   Thanks a lot !


-- 
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-23411][checkpoint] Expose Checkpoint metrics in task level [flink]

Posted by "pnowojski (via GitHub)" <gi...@apache.org>.
pnowojski closed pull request #22800: [FLINK-23411][checkpoint] Expose Checkpoint metrics in task level
URL: https://github.com/apache/flink/pull/22800


-- 
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-23411][checkpoint] Expose Checkpoint metrics in task level [flink]

Posted by "masteryhx (via GitHub)" <gi...@apache.org>.
masteryhx commented on PR #22800:
URL: https://github.com/apache/flink/pull/22800#issuecomment-1793983788

   > I'm closing that as I will be publishing a FLIP counter-proposal that uses tracing to achieve the same goal.
   
   Thanks @pnowojski for helping to push it forward, look forward to the FLIP!


-- 
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