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/10/31 08:26:02 UTC
[GitHub] [flink] reswqa opened a new pull request, #21199: [FLINK-29767] Adaptive batch scheduler supports hybrid shuffle
reswqa opened a new pull request, #21199:
URL: https://github.com/apache/flink/pull/21199
## What is the purpose of the change
*`SpeculativeScheduler` reuses the ability of `AdaptiveBatchScheduler` to schedule tasks, but the current `AdaptiveBatchScheduler` only supports ALL_ EDGES_BLOCKING batch jobs, so we should make it also support hybrid shuffle mode.*
## Brief change log
- *Introduce InputConsumableDecider and using it to decide are input all consumable for VertexwiseSchedulingStrategy.*
- *VertexwiseSchedulingStrategy supports hybrid shuffle edge.*
## Verifying this change
This change added unit tests.
## 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: yes
- The S3 file system connector: no
## Documentation
- Does this pull request introduce a new feature? 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
[GitHub] [flink] reswqa commented on a diff in pull request #21199: [FLINK-29767] Adaptive batch scheduler supports hybrid shuffle
Posted by GitBox <gi...@apache.org>.
reswqa commented on code in PR #21199:
URL: https://github.com/apache/flink/pull/21199#discussion_r1033295495
##########
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:
Changed to blocking & canBePipelined. Blocking is reserved here, because it is also a type of `ConsumingConstraint`.
--
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] reswqa commented on a diff in pull request #21199: [FLINK-29767] Adaptive batch scheduler supports hybrid shuffle
Posted by GitBox <gi...@apache.org>.
reswqa commented on code in PR #21199:
URL: https://github.com/apache/flink/pull/21199#discussion_r1043164686
##########
flink-runtime/src/main/java/org/apache/flink/runtime/scheduler/strategy/VertexwiseSchedulingStrategy.java:
##########
@@ -125,24 +122,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<>();
Review Comment:
Consider this situation using the topology as you described:
Firstly, we call `addToScheduleAndGetVertices` with only one vertex `A`, and it will becomes schedulable. Then `B&C` is added to `nextVertices`, triggering the next round `addToScheduleAndGetVertices`. If `C` goes out of the `currentVertices` set first, because `B` has not yet become schedulable, the `ConsumedPartitionGroup` where B is located will be marked as `false` in the `consumableStatusCache`. Next, `B` goes out of `currentVertices` and judges itself as scheduled. It will add `C` to the `nextVertices` again, and in the next round of `addToScheduleAndGetVertices`, `C` will judge whether it can be scheduled. Since the `consumableStatusCache` has considered `B` as false, even if B is already in the scheduled state, `C` cannot be scheduled forever.
--
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] xintongsong commented on pull request #21199: [FLINK-29767] Adaptive batch scheduler supports hybrid shuffle
Posted by GitBox <gi...@apache.org>.
xintongsong commented on PR #21199:
URL: https://github.com/apache/flink/pull/21199#issuecomment-1352467803
@zhuzhurk, thanks for reviewing. Merging this.
--
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] reswqa commented on a diff in pull request #21199: [FLINK-29767] Adaptive batch scheduler supports hybrid shuffle
Posted by GitBox <gi...@apache.org>.
reswqa commented on code in PR #21199:
URL: https://github.com/apache/flink/pull/21199#discussion_r1043082760
##########
flink-runtime/src/main/java/org/apache/flink/runtime/scheduler/strategy/InputConsumableDecider.java:
##########
@@ -33,14 +33,14 @@ 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 verticesToSchedule vertices that are not yet scheduled by already decided to be
Review Comment:
good catch.
--
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] reswqa commented on a diff in pull request #21199: [FLINK-29767] Adaptive batch scheduler supports hybrid shuffle
Posted by GitBox <gi...@apache.org>.
reswqa commented on code in PR #21199:
URL: https://github.com/apache/flink/pull/21199#discussion_r1043179571
##########
flink-runtime/src/main/java/org/apache/flink/runtime/scheduler/strategy/VertexwiseSchedulingStrategy.java:
##########
@@ -125,24 +122,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<>();
+
+ for (ExecutionVertexID currentVertex : currentVertices) {
+ if (isVertexSchedulable(currentVertex, consumableStatusCache, verticesToDeploy)) {
+ verticesToDeploy.add(currentVertex);
+ Set<ConsumerVertexGroup> canBePipelinedConsumerVertexGroups =
+ IterableUtils.toStream(
+ schedulingTopology
+ .getVertex(currentVertex)
+ .getProducedResults())
+ .map(SchedulingResultPartition::getConsumerVertexGroups)
+ .flatMap(Collection::stream)
+ .filter(
+ (consumerVertexGroup) ->
+ consumerVertexGroup
+ .getResultPartitionType()
+ .canBePipelinedConsumed())
+ .collect(Collectors.toSet());
+ for (ConsumerVertexGroup consumerVertexGroup : canBePipelinedConsumerVertexGroups) {
+ if (!visitedConsumerVertexGroup.contains(consumerVertexGroup)) {
+ visitedConsumerVertexGroup.add(consumerVertexGroup);
+ nextVertices.addAll(
+ canBePipelinedConsumerVertexGroups.stream()
Review Comment:
Yes, you're right. Fix this.
##########
flink-runtime/src/main/java/org/apache/flink/runtime/scheduler/strategy/VertexwiseSchedulingStrategy.java:
##########
@@ -125,24 +122,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<>();
+
+ for (ExecutionVertexID currentVertex : currentVertices) {
+ if (isVertexSchedulable(currentVertex, consumableStatusCache, verticesToDeploy)) {
+ verticesToDeploy.add(currentVertex);
+ Set<ConsumerVertexGroup> canBePipelinedConsumerVertexGroups =
+ IterableUtils.toStream(
+ schedulingTopology
+ .getVertex(currentVertex)
+ .getProducedResults())
+ .map(SchedulingResultPartition::getConsumerVertexGroups)
+ .flatMap(Collection::stream)
+ .filter(
+ (consumerVertexGroup) ->
+ consumerVertexGroup
+ .getResultPartitionType()
+ .canBePipelinedConsumed())
+ .collect(Collectors.toSet());
+ for (ConsumerVertexGroup consumerVertexGroup : canBePipelinedConsumerVertexGroups) {
+ if (!visitedConsumerVertexGroup.contains(consumerVertexGroup)) {
+ visitedConsumerVertexGroup.add(consumerVertexGroup);
+ nextVertices.addAll(
+ canBePipelinedConsumerVertexGroups.stream()
Review Comment:
Yes, you're right. Fixed this.
--
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] reswqa commented on a diff in pull request #21199: [FLINK-29767] Adaptive batch scheduler supports hybrid shuffle
Posted by GitBox <gi...@apache.org>.
reswqa commented on code in PR #21199:
URL: https://github.com/apache/flink/pull/21199#discussion_r1033351526
##########
flink-runtime/src/main/java/org/apache/flink/runtime/scheduler/strategy/InputConsumableDecider.java:
##########
@@ -33,14 +33,14 @@ 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 verticesToSchedule vertices that are not yet scheduled by already decided to be
+ * scheduled.
* @param consumableStatusCache a cache for {@link ConsumedPartitionGroup} consumable status.
- * This will be used to reduce double computing.
+ * This is to avoid repetitive computation.
*/
boolean isInputConsumable(
ExecutionVertexID executionVertexID,
- Set<ExecutionVertexID> verticesToDeploy,
+ Set<ExecutionVertexID> verticesToSchedule,
Review Comment:
Ah, I forgot to change it.
##########
flink-runtime/src/main/java/org/apache/flink/runtime/scheduler/strategy/ConsumedPartitionGroup.java:
##########
@@ -132,4 +133,25 @@ public boolean areAllPartitionsFinished() {
public ResultPartitionType getResultPartitionType() {
return resultPartitionType;
}
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ ConsumedPartitionGroup that = (ConsumedPartitionGroup) o;
+ return numConsumers == that.numConsumers
+ && Objects.equals(resultPartitions, that.resultPartitions)
+ && Objects.equals(intermediateDataSetID, that.intermediateDataSetID)
+ && resultPartitionType == that.resultPartitionType;
+ }
Review Comment:
Make sense, fixed it.
--
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] xintongsong commented on a diff in pull request #21199: [FLINK-29767] Adaptive batch scheduler supports hybrid shuffle
Posted by GitBox <gi...@apache.org>.
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
[GitHub] [flink] reswqa commented on pull request #21199: [FLINK-29767] Adaptive batch scheduler supports hybrid shuffle
Posted by GitBox <gi...@apache.org>.
reswqa commented on PR #21199:
URL: https://github.com/apache/flink/pull/21199#issuecomment-1350592950
@zhuzhurk Thank you for reminding me to benchmark the scheduling performance. I tested the `SchedulingDownstreamTasksInBatchJobBenchmark ` locally with `VertexwiseSchedulingStrategy ` and `4000 * 4000` parallelism. There was no obvious performance gap before and after this pull request. In both cases, the execution time of single test was between 2 and 3 seconds.
--
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] xintongsong closed pull request #21199: [FLINK-29767] Adaptive batch scheduler supports hybrid shuffle
Posted by GitBox <gi...@apache.org>.
xintongsong closed pull request #21199: [FLINK-29767] Adaptive batch scheduler supports hybrid shuffle
URL: https://github.com/apache/flink/pull/21199
--
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] reswqa commented on pull request #21199: [FLINK-29767] Adaptive batch scheduler supports hybrid shuffle
Posted by GitBox <gi...@apache.org>.
reswqa commented on PR #21199:
URL: https://github.com/apache/flink/pull/21199#issuecomment-1328787677
@xintongsong Thanks for the review, I have rebased and updated this pr in fix-up commit.
--
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] reswqa commented on pull request #21199: [FLINK-29767] Adaptive batch scheduler supports hybrid shuffle
Posted by GitBox <gi...@apache.org>.
reswqa commented on PR #21199:
URL: https://github.com/apache/flink/pull/21199#issuecomment-1342479002
@zhuzhurk Thanks for the review, I just rebase all the previous fix-up commit, and then add some fix-up commit to your comments. After resolving some conflicts, they are not at the end of all the commit, but they are closely followed by the corresponding commit to fix. PTAL~
--
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] reswqa commented on a diff in pull request #21199: [FLINK-29767] Adaptive batch scheduler supports hybrid shuffle
Posted by GitBox <gi...@apache.org>.
reswqa commented on code in PR #21199:
URL: https://github.com/apache/flink/pull/21199#discussion_r1033295495
##########
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:
changed to blocking & canBePipelined.
--
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] reswqa commented on a diff in pull request #21199: [FLINK-29767] Adaptive batch scheduler supports hybrid shuffle
Posted by GitBox <gi...@apache.org>.
reswqa commented on code in PR #21199:
URL: https://github.com/apache/flink/pull/21199#discussion_r1043164686
##########
flink-runtime/src/main/java/org/apache/flink/runtime/scheduler/strategy/VertexwiseSchedulingStrategy.java:
##########
@@ -125,24 +122,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<>();
Review Comment:
Consider this situation using the topology as you described:
Firstly, we call `addToScheduleAndGetVertices` with only one vertex `A`, and it will becomes schedulable. Then `B&C` is added to `nextVertices`, triggering the next round `addToScheduleAndGetVertices`. If `C` goes out of the `currentVertices` set first, because `B` has not yet become schedulable, the `ConsumedPartitionGroup` where B is located will be marked as `false` in the `consumableStatusCache`. Next, `B` goes out of `currentVertices` and judges itself as scheduled. It will add `C` to the `nextVertices` again, and in the next round of `addToScheduleAndGetVertices`, `C` will judge whether it can be scheduled. Since the `consumableStatusCache` has considered `B` as false, even if B is already in the scheduled state, `C` cannot be scheduled forever.
The above example only considers the reuse of `consumableStatusCache` in the multiple calls of `addToScheduleAndGetVertices`. If the reuse of `visitedConsumerVertexGroup` is added, `C` will not even be added to `nextVertices` for the second time.
##########
flink-runtime/src/main/java/org/apache/flink/runtime/scheduler/strategy/VertexwiseSchedulingStrategy.java:
##########
@@ -125,24 +122,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<>();
Review Comment:
Consider this situation using the topology as you described:
Firstly, we call `addToScheduleAndGetVertices` with only one vertex `A`, and it will becomes schedulable. Then `B&C` is added to `nextVertices`, triggering the next round `addToScheduleAndGetVertices`. If `C` goes out of the `currentVertices` set first, because `B` has not yet become schedulable, the `ConsumedPartitionGroup` where B is located will be marked as `false` in the `consumableStatusCache`. Next, `B` goes out of `currentVertices` and judges itself as scheduled. It will add `C` to the `nextVertices` again, and in the next round of `addToScheduleAndGetVertices`, `C` will judge whether it can be scheduled. Since the `consumableStatusCache` has considered `B` as false, even if B is already in the scheduled state, `C` cannot be scheduled forever.
The above example only considers the reuse of `consumableStatusCache` in the multiple calls of `addToScheduleAndGetVertices`. If the reuse of `visitedConsumerVertexGroup` is added, `C` will not even be added to `nextVertices` for the second time.
--
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] zhuzhurk commented on a diff in pull request #21199: [FLINK-29767] Adaptive batch scheduler supports hybrid shuffle
Posted by GitBox <gi...@apache.org>.
zhuzhurk commented on code in PR #21199:
URL: https://github.com/apache/flink/pull/21199#discussion_r1042889689
##########
flink-runtime/src/main/java/org/apache/flink/runtime/scheduler/strategy/InputConsumableDecider.java:
##########
@@ -33,14 +33,14 @@ 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 verticesToSchedule vertices that are not yet scheduled by already decided to be
Review Comment:
by -> but
##########
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
Review Comment:
weather -> whether
There are a few other occurrences.
##########
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,
Review Comment:
executionVertexID -> executionVertexId
##########
flink-runtime/src/main/java/org/apache/flink/runtime/scheduler/strategy/VertexwiseSchedulingStrategy.java:
##########
@@ -123,12 +132,15 @@ private void maybeScheduleVertices(final Set<ExecutionVertexID> vertices) {
SchedulingExecutionVertex vertex =
schedulingTopology.getVertex(vertexId);
checkState(vertex.getState() == ExecutionState.CREATED);
- return areVertexInputsAllConsumable(
- vertex, consumableStatusCache);
+ return inputConsumableDecider.isInputConsumable(
+ vertexId,
Review Comment:
It's better to pass in a `SchedulingExecutionVertex` so that we do not need to find the vertex by the id multiple times.
##########
flink-runtime/src/main/java/org/apache/flink/runtime/scheduler/strategy/VertexwiseSchedulingStrategy.java:
##########
@@ -125,24 +122,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<>();
Review Comment:
I think it's more efficient to reuse the cache across different `addToDeployAndGetVertices`. So is `visitedConsumerVertexGroup`.
e.g. A->B, B->C, A->C, all edges are hybrid, B&C consume the same result R. Seems currently C will be visited twice, and the consumable state of R will be computed twice.
##########
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:
I prefer to use `IdentityHashMap` and `Collections.newSetFromMap(new IdentityHashMap<>())`. Because we never expect a same ConsumedPartitionGroup to be created multiple times. And directly comparing the references is more efficient.
I also noticed the current implementation of their `equals()`/`hashCode()` is a bit tricky so it's better to just avoid making that change.
##########
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.
+ */
+public class DefaultInputConsumableDecider implements InputConsumableDecider {
+ private final Function<ExecutionVertexID, SchedulingExecutionVertex> executionVertexRetriever;
+
+ private final Function<IntermediateResultPartitionID, SchedulingResultPartition>
+ resultPartitionRetriever;
+
+ private final Function<ExecutionVertexID, Boolean> scheduledVertexRetriever;
+
+ public DefaultInputConsumableDecider(
Review Comment:
can be package private
##########
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.
+ */
+public class DefaultInputConsumableDecider implements InputConsumableDecider {
+ private final Function<ExecutionVertexID, SchedulingExecutionVertex> executionVertexRetriever;
+
+ private final Function<IntermediateResultPartitionID, SchedulingResultPartition>
+ resultPartitionRetriever;
+
+ private final Function<ExecutionVertexID, Boolean> scheduledVertexRetriever;
+
+ public DefaultInputConsumableDecider(
+ Function<ExecutionVertexID, Boolean> scheduledVertexRetriever,
+ Function<ExecutionVertexID, SchedulingExecutionVertex> executionVertexRetriever,
+ Function<IntermediateResultPartitionID, SchedulingResultPartition>
+ resultPartitionRetriever) {
+ this.scheduledVertexRetriever = scheduledVertexRetriever;
+ this.executionVertexRetriever = executionVertexRetriever;
+ this.resultPartitionRetriever = resultPartitionRetriever;
+ }
+
+ @Override
+ public boolean isInputConsumable(
+ ExecutionVertexID executionVertexID,
Review Comment:
executionVertexID -> executionVertexId
##########
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.
+ */
+public class DefaultInputConsumableDecider implements InputConsumableDecider {
Review Comment:
can be package private
##########
flink-runtime/src/main/java/org/apache/flink/runtime/scheduler/strategy/VertexwiseSchedulingStrategy.java:
##########
@@ -125,24 +122,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<>();
+
+ for (ExecutionVertexID currentVertex : currentVertices) {
+ if (isVertexSchedulable(currentVertex, consumableStatusCache, verticesToDeploy)) {
+ verticesToDeploy.add(currentVertex);
+ Set<ConsumerVertexGroup> canBePipelinedConsumerVertexGroups =
+ IterableUtils.toStream(
+ schedulingTopology
+ .getVertex(currentVertex)
+ .getProducedResults())
+ .map(SchedulingResultPartition::getConsumerVertexGroups)
+ .flatMap(Collection::stream)
+ .filter(
+ (consumerVertexGroup) ->
+ consumerVertexGroup
+ .getResultPartitionType()
+ .canBePipelinedConsumed())
+ .collect(Collectors.toSet());
+ for (ConsumerVertexGroup consumerVertexGroup : canBePipelinedConsumerVertexGroups) {
+ if (!visitedConsumerVertexGroup.contains(consumerVertexGroup)) {
+ visitedConsumerVertexGroup.add(consumerVertexGroup);
+ nextVertices.addAll(
+ canBePipelinedConsumerVertexGroups.stream()
Review Comment:
I guess here we should only add vertices of the `consumerVertexGroup`?
--
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] xintongsong commented on a diff in pull request #21199: [FLINK-29767] Adaptive batch scheduler supports hybrid shuffle
Posted by GitBox <gi...@apache.org>.
xintongsong commented on code in PR #21199:
URL: https://github.com/apache/flink/pull/21199#discussion_r1033324043
##########
flink-runtime/src/main/java/org/apache/flink/runtime/scheduler/strategy/InputConsumableDecider.java:
##########
@@ -33,14 +33,14 @@ 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 verticesToSchedule vertices that are not yet scheduled by already decided to be
+ * scheduled.
* @param consumableStatusCache a cache for {@link ConsumedPartitionGroup} consumable status.
- * This will be used to reduce double computing.
+ * This is to avoid repetitive computation.
*/
boolean isInputConsumable(
ExecutionVertexID executionVertexID,
- Set<ExecutionVertexID> verticesToDeploy,
+ Set<ExecutionVertexID> verticesToSchedule,
Review Comment:
This naming issue stays not only in this interface, but also in its implementation and the calculation logics in the strategy.
##########
flink-runtime/src/main/java/org/apache/flink/runtime/scheduler/strategy/ConsumedPartitionGroup.java:
##########
@@ -132,4 +133,25 @@ public boolean areAllPartitionsFinished() {
public ResultPartitionType getResultPartitionType() {
return resultPartitionType;
}
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ ConsumedPartitionGroup that = (ConsumedPartitionGroup) o;
+ return numConsumers == that.numConsumers
+ && Objects.equals(resultPartitions, that.resultPartitions)
+ && Objects.equals(intermediateDataSetID, that.intermediateDataSetID)
+ && resultPartitionType == that.resultPartitionType;
+ }
Review Comment:
What if there are two `ConsumedPartitionGroup` that are "equal" while having different `unfinishedPartitions`? Which one should be used?
We probably want to make sure for each group there's at most one `ConsumedPartitionGroup` object. Thus, `this` and `o` are equal only if they are the same object.
--
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 #21199: [FLINK-29767] Adaptive batch scheduler supports hybrid shuffle
Posted by GitBox <gi...@apache.org>.
flinkbot commented on PR #21199:
URL: https://github.com/apache/flink/pull/21199#issuecomment-1296766860
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "a91b1ee02d73a92d7f4f175a7237e7064d7bd1d1",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "a91b1ee02d73a92d7f4f175a7237e7064d7bd1d1",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* a91b1ee02d73a92d7f4f175a7237e7064d7bd1d1 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] reswqa commented on a diff in pull request #21199: [FLINK-29767] Adaptive batch scheduler supports hybrid shuffle
Posted by GitBox <gi...@apache.org>.
reswqa commented on code in PR #21199:
URL: https://github.com/apache/flink/pull/21199#discussion_r1043124374
##########
flink-runtime/src/main/java/org/apache/flink/runtime/scheduler/strategy/VertexwiseSchedulingStrategy.java:
##########
@@ -123,12 +132,15 @@ private void maybeScheduleVertices(final Set<ExecutionVertexID> vertices) {
SchedulingExecutionVertex vertex =
schedulingTopology.getVertex(vertexId);
checkState(vertex.getState() == ExecutionState.CREATED);
- return areVertexInputsAllConsumable(
- vertex, consumableStatusCache);
+ return inputConsumableDecider.isInputConsumable(
+ vertexId,
Review Comment:
changed.
--
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