You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2022/11/28 08:22:27 UTC

[GitHub] [flink] xintongsong commented on a diff in pull request #21199: [FLINK-29767] Adaptive batch scheduler supports hybrid shuffle

xintongsong commented on code in PR #21199:
URL: https://github.com/apache/flink/pull/21199#discussion_r1033236880


##########
flink-runtime/src/main/java/org/apache/flink/runtime/scheduler/strategy/VertexwiseSchedulingStrategy.java:
##########
@@ -125,24 +124,64 @@ private void maybeScheduleVertices(final Set<ExecutionVertexID> vertices) {
             newVertices.clear();
         }
 
-        final Set<ExecutionVertexID> verticesToDeploy =
-                allCandidates.stream()
-                        .filter(
-                                vertexId -> {
-                                    SchedulingExecutionVertex vertex =
-                                            schedulingTopology.getVertex(vertexId);
-                                    checkState(vertex.getState() == ExecutionState.CREATED);
-                                    return inputConsumableDecider.isInputConsumable(
-                                            vertexId,
-                                            Collections.emptySet(),
-                                            consumableStatusCache);
-                                })
-                        .collect(Collectors.toSet());
+        final Set<ExecutionVertexID> verticesToDeploy = new HashSet<>();
+
+        Set<ExecutionVertexID> nextVertices = allCandidates;
+        while (!nextVertices.isEmpty()) {
+            nextVertices = addToDeployAndGetVertices(nextVertices, verticesToDeploy);
+        }
 
         scheduleVerticesOneByOne(verticesToDeploy);
         scheduledVertices.addAll(verticesToDeploy);
     }
 
+    private Set<ExecutionVertexID> addToDeployAndGetVertices(
+            Set<ExecutionVertexID> currentVertices, Set<ExecutionVertexID> verticesToDeploy) {
+        Set<ExecutionVertexID> nextVertices = new HashSet<>();
+        // cache consumedPartitionGroup's consumable status to avoid compute repeatedly.
+        final Map<ConsumedPartitionGroup, Boolean> consumableStatusCache = new HashMap<>();
+        final Set<ConsumerVertexGroup> visitedConsumerVertexGroup = new HashSet<>();

Review Comment:
   For `ConsumedPartitionGroup` and `ConsumerVertexGroup` that used in `HashMap` and `HashSet`, it would be better to explicitly implement `equals()` and `hashCode()` methods.



##########
flink-runtime/src/main/java/org/apache/flink/runtime/scheduler/strategy/InputConsumableDecider.java:
##########
@@ -0,0 +1,52 @@
+/*
+ * 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.scheduler.strategy;
+
+import org.apache.flink.runtime.executiongraph.ExecutionVertex;
+
+import java.util.Map;
+import java.util.Set;
+import java.util.function.Function;
+
+/**
+ * {@link InputConsumableDecider} is responsible for determining weather the input of an
+ * executionVertex is consumable.
+ */
+public interface InputConsumableDecider {
+    /**
+     * Determining weather the input of an execution vertex is consumable.
+     *
+     * @param executionVertexID identifier of this {@link ExecutionVertex}.
+     * @param verticesToDeploy all vertices to deploy during the current scheduling process. This
+     *     set will be used to know whether an execution vertex has been decided to scheduled.
+     * @param consumableStatusCache a cache for {@link ConsumedPartitionGroup} consumable status.
+     *     This will be used to reduce double computing.

Review Comment:
   ```
   @param consumableStatusCache a cache for {@link ConsumedPartitionGroup} consumable status. This is to avoid repeatitive computation.
   ```



##########
flink-runtime/src/main/java/org/apache/flink/runtime/scheduler/strategy/InputConsumableDecider.java:
##########
@@ -0,0 +1,52 @@
+/*
+ * 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.scheduler.strategy;
+
+import org.apache.flink.runtime.executiongraph.ExecutionVertex;
+
+import java.util.Map;
+import java.util.Set;
+import java.util.function.Function;
+
+/**
+ * {@link InputConsumableDecider} is responsible for determining weather the input of an
+ * executionVertex is consumable.
+ */
+public interface InputConsumableDecider {
+    /**
+     * Determining weather the input of an execution vertex is consumable.
+     *
+     * @param executionVertexID identifier of this {@link ExecutionVertex}.
+     * @param verticesToDeploy all vertices to deploy during the current scheduling process. This
+     *     set will be used to know whether an execution vertex has been decided to scheduled.

Review Comment:
   ```
   @param verticesToSchedule vertices that are not yet scheduled by already decided to be scheduled.
   ```



##########
flink-runtime/src/main/java/org/apache/flink/runtime/scheduler/strategy/InputConsumableDecider.java:
##########
@@ -0,0 +1,52 @@
+/*
+ * 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.scheduler.strategy;
+
+import org.apache.flink.runtime.executiongraph.ExecutionVertex;
+
+import java.util.Map;
+import java.util.Set;
+import java.util.function.Function;
+
+/**
+ * {@link InputConsumableDecider} is responsible for determining weather the input of an
+ * executionVertex is consumable.
+ */
+public interface InputConsumableDecider {
+    /**
+     * Determining weather the input of an execution vertex is consumable.
+     *
+     * @param executionVertexID identifier of this {@link ExecutionVertex}.
+     * @param verticesToDeploy all vertices to deploy during the current scheduling process. This
+     *     set will be used to know whether an execution vertex has been decided to scheduled.
+     * @param consumableStatusCache a cache for {@link ConsumedPartitionGroup} consumable status.
+     *     This will be used to reduce double computing.
+     */
+    boolean isInputConsumable(
+            ExecutionVertexID executionVertexID,
+            Set<ExecutionVertexID> verticesToDeploy,

Review Comment:
   `verticesToSchedule`



##########
flink-runtime/src/main/java/org/apache/flink/runtime/scheduler/strategy/DefaultInputConsumableDecider.java:
##########
@@ -0,0 +1,114 @@
+/*
+ * 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.scheduler.strategy;
+
+import org.apache.flink.runtime.jobgraph.IntermediateResultPartitionID;
+
+import java.util.Map;
+import java.util.Set;
+import java.util.function.Function;
+
+/**
+ * Default implementation of {@link InputConsumableDecider}. This decider will judge whether the
+ * executionVertex's inputs are consumable as follows:
+ *
+ * <p>For blocking consumed partition group: Whether all result partitions in the group are
+ * finished.
+ *
+ * <p>For hybrid consumed partition group: whether all result partitions in the group are scheduled.

Review Comment:
   Use `canBePipelined` rather than `blocking/hybrid`.



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