zhuzhurk commented on code in PR #25552: URL: https://github.com/apache/flink/pull/25552#discussion_r1908227467
########## flink-runtime/src/test/java/org/apache/flink/runtime/scheduler/adaptivebatch/util/PointwiseVertexInputInfoComputerTest.java: ########## @@ -0,0 +1,124 @@ +/* + * 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.adaptivebatch.util; + +import org.apache.flink.runtime.executiongraph.IndexRange; +import org.apache.flink.runtime.executiongraph.JobVertexInputInfo; +import org.apache.flink.runtime.jobgraph.IntermediateDataSetID; +import org.apache.flink.runtime.scheduler.adaptivebatch.BlockingInputInfo; +import org.apache.flink.runtime.scheduler.adaptivebatch.VertexInputInfoComputerTestUtil; + +import org.junit.jupiter.api.Test; + +import java.util.List; +import java.util.Map; + +import static org.apache.flink.runtime.scheduler.adaptivebatch.VertexInputInfoComputerTestUtil.checkJobVertexInputInfo; + +/** Tests for {@link PointwiseVertexInputInfoComputer}. */ +class PointwiseVertexInputInfoComputerTest { + + @Test + void testComputePointwiseInputWithoutSkewed() { + PointwiseVertexInputInfoComputer computer = createPointwiseVertexInputInfoComputer(); + List<BlockingInputInfo> inputInfos = createBlockingInputInfos(2, List.of()); + Map<IntermediateDataSetID, JobVertexInputInfo> vertexInputs = + computer.compute(inputInfos, 2); + List<Map<IndexRange, IndexRange>> targetConsumedSubpartitionGroups = + List.of( + Map.of(new IndexRange(0, 0), new IndexRange(0, 2)), + Map.of(new IndexRange(1, 1), new IndexRange(0, 2))); + checkJobVertexInputInfo(2, inputInfos, targetConsumedSubpartitionGroups, vertexInputs); + + Map<IntermediateDataSetID, JobVertexInputInfo> vertexInputs2 = + computer.compute(inputInfos, 3); + List<Map<IndexRange, IndexRange>> targetConsumedSubpartitionGroups2 = + List.of( + Map.of(new IndexRange(0, 0), new IndexRange(0, 1)), + Map.of( + new IndexRange(0, 0), + new IndexRange(2, 2), + new IndexRange(1, 1), + new IndexRange(0, 0)), + Map.of(new IndexRange(1, 1), new IndexRange(1, 2))); + checkJobVertexInputInfo(3, inputInfos, targetConsumedSubpartitionGroups2, vertexInputs2); + } + + @Test + void testComputeVertexInputInfoPointwiseInputWithSkewed() { Review Comment: -> testComputePointwiseInputWithSkewedPartition ########## flink-runtime/src/test/java/org/apache/flink/runtime/scheduler/adaptivebatch/util/PointwiseVertexInputInfoComputerTest.java: ########## @@ -0,0 +1,124 @@ +/* + * 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.adaptivebatch.util; + +import org.apache.flink.runtime.executiongraph.IndexRange; +import org.apache.flink.runtime.executiongraph.JobVertexInputInfo; +import org.apache.flink.runtime.jobgraph.IntermediateDataSetID; +import org.apache.flink.runtime.scheduler.adaptivebatch.BlockingInputInfo; +import org.apache.flink.runtime.scheduler.adaptivebatch.VertexInputInfoComputerTestUtil; + +import org.junit.jupiter.api.Test; + +import java.util.List; +import java.util.Map; + +import static org.apache.flink.runtime.scheduler.adaptivebatch.VertexInputInfoComputerTestUtil.checkJobVertexInputInfo; + +/** Tests for {@link PointwiseVertexInputInfoComputer}. */ +class PointwiseVertexInputInfoComputerTest { + + @Test + void testComputePointwiseInputWithoutSkewed() { + PointwiseVertexInputInfoComputer computer = createPointwiseVertexInputInfoComputer(); + List<BlockingInputInfo> inputInfos = createBlockingInputInfos(2, List.of()); Review Comment: Could you add a case to test inputs with different numPartitions? And a case to test inputs with different numSubpartitions? ########## flink-runtime/src/test/java/org/apache/flink/runtime/scheduler/adaptivebatch/util/AllToAllVertexInputInfoComputerTest.java: ########## @@ -0,0 +1,313 @@ +/* + * 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.adaptivebatch.util; + +import org.apache.flink.runtime.executiongraph.IndexRange; +import org.apache.flink.runtime.executiongraph.JobVertexInputInfo; +import org.apache.flink.runtime.jobgraph.IntermediateDataSetID; +import org.apache.flink.runtime.jobgraph.JobVertexID; +import org.apache.flink.runtime.scheduler.adaptivebatch.BlockingInputInfo; +import org.apache.flink.runtime.scheduler.adaptivebatch.VertexInputInfoComputerTestUtil; + +import org.junit.jupiter.api.Test; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import static org.apache.flink.runtime.scheduler.adaptivebatch.VertexInputInfoComputerTestUtil.checkJobVertexInputInfo; + +/** Tests for {@link AllToAllVertexInputInfoComputer}. */ +class AllToAllVertexInputInfoComputerTest { + + @Test + void testComputeAllInputExistIntraInputKeyCorrelation() { Review Comment: -> testComputeSkewedInputWithIntraInputKeyCorrelation ########## flink-runtime/src/test/java/org/apache/flink/runtime/scheduler/adaptivebatch/util/PointwiseVertexInputInfoComputerTest.java: ########## @@ -0,0 +1,124 @@ +/* + * 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.adaptivebatch.util; + +import org.apache.flink.runtime.executiongraph.IndexRange; +import org.apache.flink.runtime.executiongraph.JobVertexInputInfo; +import org.apache.flink.runtime.jobgraph.IntermediateDataSetID; +import org.apache.flink.runtime.scheduler.adaptivebatch.BlockingInputInfo; +import org.apache.flink.runtime.scheduler.adaptivebatch.VertexInputInfoComputerTestUtil; + +import org.junit.jupiter.api.Test; + +import java.util.List; +import java.util.Map; + +import static org.apache.flink.runtime.scheduler.adaptivebatch.VertexInputInfoComputerTestUtil.checkJobVertexInputInfo; + +/** Tests for {@link PointwiseVertexInputInfoComputer}. */ +class PointwiseVertexInputInfoComputerTest { + + @Test + void testComputePointwiseInputWithoutSkewed() { + PointwiseVertexInputInfoComputer computer = createPointwiseVertexInputInfoComputer(); + List<BlockingInputInfo> inputInfos = createBlockingInputInfos(2, List.of()); + Map<IntermediateDataSetID, JobVertexInputInfo> vertexInputs = + computer.compute(inputInfos, 2); + List<Map<IndexRange, IndexRange>> targetConsumedSubpartitionGroups = + List.of( + Map.of(new IndexRange(0, 0), new IndexRange(0, 2)), + Map.of(new IndexRange(1, 1), new IndexRange(0, 2))); + checkJobVertexInputInfo(2, inputInfos, targetConsumedSubpartitionGroups, vertexInputs); + + Map<IntermediateDataSetID, JobVertexInputInfo> vertexInputs2 = + computer.compute(inputInfos, 3); + List<Map<IndexRange, IndexRange>> targetConsumedSubpartitionGroups2 = + List.of( + Map.of(new IndexRange(0, 0), new IndexRange(0, 1)), + Map.of( + new IndexRange(0, 0), + new IndexRange(2, 2), + new IndexRange(1, 1), + new IndexRange(0, 0)), + Map.of(new IndexRange(1, 1), new IndexRange(1, 2))); + checkJobVertexInputInfo(3, inputInfos, targetConsumedSubpartitionGroups2, vertexInputs2); + } + + @Test + void testComputeVertexInputInfoPointwiseInputWithSkewed() { + PointwiseVertexInputInfoComputer computer = createPointwiseVertexInputInfoComputer(); + List<BlockingInputInfo> inputInfos = createBlockingInputInfos(3, List.of(0)); + Map<IntermediateDataSetID, JobVertexInputInfo> vertexInputs = + computer.compute(inputInfos, 3); + List<Map<IndexRange, IndexRange>> targetConsumedSubpartitionGroups = + List.of( + Map.of(new IndexRange(0, 0), new IndexRange(0, 0)), + Map.of(new IndexRange(0, 0), new IndexRange(1, 1)), + Map.of( + new IndexRange(0, 0), + new IndexRange(2, 2), + new IndexRange(1, 2), + new IndexRange(0, 2))); + checkJobVertexInputInfo(3, inputInfos, targetConsumedSubpartitionGroups, vertexInputs); Review Comment: Could you also test `computer.compute(inputInfos, 4)` and `computer.compute(inputInfos, 2)` for these inputs? ########## flink-runtime/src/test/java/org/apache/flink/runtime/scheduler/adaptivebatch/util/PointwiseVertexInputInfoComputerTest.java: ########## @@ -0,0 +1,124 @@ +/* + * 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.adaptivebatch.util; + +import org.apache.flink.runtime.executiongraph.IndexRange; +import org.apache.flink.runtime.executiongraph.JobVertexInputInfo; +import org.apache.flink.runtime.jobgraph.IntermediateDataSetID; +import org.apache.flink.runtime.scheduler.adaptivebatch.BlockingInputInfo; +import org.apache.flink.runtime.scheduler.adaptivebatch.VertexInputInfoComputerTestUtil; + +import org.junit.jupiter.api.Test; + +import java.util.List; +import java.util.Map; + +import static org.apache.flink.runtime.scheduler.adaptivebatch.VertexInputInfoComputerTestUtil.checkJobVertexInputInfo; + +/** Tests for {@link PointwiseVertexInputInfoComputer}. */ +class PointwiseVertexInputInfoComputerTest { + + @Test + void testComputePointwiseInputWithoutSkewed() { + PointwiseVertexInputInfoComputer computer = createPointwiseVertexInputInfoComputer(); + List<BlockingInputInfo> inputInfos = createBlockingInputInfos(2, List.of()); + Map<IntermediateDataSetID, JobVertexInputInfo> vertexInputs = + computer.compute(inputInfos, 2); + List<Map<IndexRange, IndexRange>> targetConsumedSubpartitionGroups = + List.of( + Map.of(new IndexRange(0, 0), new IndexRange(0, 2)), + Map.of(new IndexRange(1, 1), new IndexRange(0, 2))); + checkJobVertexInputInfo(2, inputInfos, targetConsumedSubpartitionGroups, vertexInputs); + + Map<IntermediateDataSetID, JobVertexInputInfo> vertexInputs2 = + computer.compute(inputInfos, 3); + List<Map<IndexRange, IndexRange>> targetConsumedSubpartitionGroups2 = + List.of( + Map.of(new IndexRange(0, 0), new IndexRange(0, 1)), + Map.of( + new IndexRange(0, 0), + new IndexRange(2, 2), + new IndexRange(1, 1), + new IndexRange(0, 0)), + Map.of(new IndexRange(1, 1), new IndexRange(1, 2))); + checkJobVertexInputInfo(3, inputInfos, targetConsumedSubpartitionGroups2, vertexInputs2); + } + + @Test + void testComputeVertexInputInfoPointwiseInputWithSkewed() { + PointwiseVertexInputInfoComputer computer = createPointwiseVertexInputInfoComputer(); + List<BlockingInputInfo> inputInfos = createBlockingInputInfos(3, List.of(0)); + Map<IntermediateDataSetID, JobVertexInputInfo> vertexInputs = + computer.compute(inputInfos, 3); + List<Map<IndexRange, IndexRange>> targetConsumedSubpartitionGroups = + List.of( + Map.of(new IndexRange(0, 0), new IndexRange(0, 0)), + Map.of(new IndexRange(0, 0), new IndexRange(1, 1)), + Map.of( + new IndexRange(0, 0), + new IndexRange(2, 2), + new IndexRange(1, 2), + new IndexRange(0, 2))); + checkJobVertexInputInfo(3, inputInfos, targetConsumedSubpartitionGroups, vertexInputs); + + List<BlockingInputInfo> inputInfos2 = createBlockingInputInfos(3, List.of(1)); + Map<IntermediateDataSetID, JobVertexInputInfo> vertexInputs2 = + computer.compute(inputInfos2, 3); + List<Map<IndexRange, IndexRange>> targetConsumedSubpartitionGroups2 = + List.of( + Map.of( + new IndexRange(0, 0), + new IndexRange(0, 2), + new IndexRange(1, 1), + new IndexRange(0, 0)), + Map.of(new IndexRange(1, 1), new IndexRange(1, 1)), + Map.of( + new IndexRange(1, 1), + new IndexRange(2, 2), + new IndexRange(2, 2), + new IndexRange(0, 2))); + checkJobVertexInputInfo(3, inputInfos2, targetConsumedSubpartitionGroups2, vertexInputs2); + } + + private static List<BlockingInputInfo> createBlockingInputInfos( + int numPartitions, List<Integer> skewedPartitionIndex) { + return List.of(createBlockingInputInfo(numPartitions, skewedPartitionIndex)); + } + + private static BlockingInputInfo createBlockingInputInfo( + int numPartitions, List<Integer> skewedPartitionIndex) { + return VertexInputInfoComputerTestUtil.createBlockingInputInfos( + 1, + 1, + numPartitions, + 3, Review Comment: It's better to make `numSubpartitions` an explicit param. ########## flink-runtime/src/test/java/org/apache/flink/runtime/scheduler/adaptivebatch/util/AllToAllVertexInputInfoComputerTest.java: ########## @@ -0,0 +1,313 @@ +/* + * 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.adaptivebatch.util; + +import org.apache.flink.runtime.executiongraph.IndexRange; +import org.apache.flink.runtime.executiongraph.JobVertexInputInfo; +import org.apache.flink.runtime.jobgraph.IntermediateDataSetID; +import org.apache.flink.runtime.jobgraph.JobVertexID; +import org.apache.flink.runtime.scheduler.adaptivebatch.BlockingInputInfo; +import org.apache.flink.runtime.scheduler.adaptivebatch.VertexInputInfoComputerTestUtil; + +import org.junit.jupiter.api.Test; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import static org.apache.flink.runtime.scheduler.adaptivebatch.VertexInputInfoComputerTestUtil.checkJobVertexInputInfo; + +/** Tests for {@link AllToAllVertexInputInfoComputer}. */ +class AllToAllVertexInputInfoComputerTest { + + @Test + void testComputeAllInputExistIntraInputKeyCorrelation() { + testComputeAllInputExistIntraInputKeyCorrelation(1); + testComputeAllInputExistIntraInputKeyCorrelation(10); + } + + void testComputeAllInputExistIntraInputKeyCorrelation(int numInputInfos) { + AllToAllVertexInputInfoComputer computer = createAllToAllVertexInputInfoComputer(); + List<BlockingInputInfo> inputInfos = new ArrayList<>(); + List<BlockingInputInfo> leftInputInfos = + createBlockingInputInfos(1, numInputInfos, 10, true, true, List.of(0)); + List<BlockingInputInfo> rightInputInfos = + createBlockingInputInfos(2, numInputInfos, 10, true, true, List.of()); + inputInfos.addAll(leftInputInfos); + inputInfos.addAll(rightInputInfos); + Map<IntermediateDataSetID, JobVertexInputInfo> vertexInputs = + computer.compute(new JobVertexID(), inputInfos, 10, 1, 10); + List<Map<IndexRange, IndexRange>> targetConsumedSubpartitionGroups = + List.of( + Map.of(new IndexRange(0, 9), new IndexRange(0, 0)), + Map.of(new IndexRange(0, 9), new IndexRange(1, 1)), + Map.of(new IndexRange(0, 9), new IndexRange(2, 2))); + checkJobVertexInputInfo(3, inputInfos, targetConsumedSubpartitionGroups, vertexInputs); + } + + @Test + void testComputeOneSkewedInputNotExistIntraInputKeyCorrelation() { + testComputeOneSkewedInputNotExistIntraInputKeyCorrelation(1); + testComputeOneSkewedInputNotExistIntraInputKeyCorrelation(10); + } + + void testComputeOneSkewedInputNotExistIntraInputKeyCorrelation(int numInputInfos) { + AllToAllVertexInputInfoComputer computer = createAllToAllVertexInputInfoComputer(); + List<BlockingInputInfo> inputInfos = new ArrayList<>(); + List<BlockingInputInfo> leftInputInfos = + createBlockingInputInfos(1, numInputInfos, 10, false, true, List.of(0)); + List<BlockingInputInfo> rightInputInfos = + createBlockingInputInfos(2, numInputInfos, 10, true, true, List.of()); + inputInfos.addAll(leftInputInfos); + inputInfos.addAll(rightInputInfos); + Map<IntermediateDataSetID, JobVertexInputInfo> vertexInputs = + computer.compute(new JobVertexID(), inputInfos, 10, 1, 10); + List<Map<IndexRange, IndexRange>> leftTargetConsumedSubpartitionGroups = + List.of( + Map.of(new IndexRange(0, 1), new IndexRange(0, 0)), + Map.of(new IndexRange(2, 3), new IndexRange(0, 0)), + Map.of(new IndexRange(4, 5), new IndexRange(0, 0)), + Map.of(new IndexRange(6, 7), new IndexRange(0, 0)), + Map.of(new IndexRange(8, 9), new IndexRange(0, 0)), + Map.of(new IndexRange(0, 9), new IndexRange(1, 1)), + Map.of(new IndexRange(0, 9), new IndexRange(2, 2))); + checkJobVertexInputInfo( + 7, leftInputInfos, leftTargetConsumedSubpartitionGroups, vertexInputs); + List<Map<IndexRange, IndexRange>> rightTargetConsumedSubpartitionGroups = + List.of( + Map.of(new IndexRange(0, 9), new IndexRange(0, 0)), + Map.of(new IndexRange(0, 9), new IndexRange(0, 0)), + Map.of(new IndexRange(0, 9), new IndexRange(0, 0)), + Map.of(new IndexRange(0, 9), new IndexRange(0, 0)), + Map.of(new IndexRange(0, 9), new IndexRange(0, 0)), + Map.of(new IndexRange(0, 9), new IndexRange(1, 1)), + Map.of(new IndexRange(0, 9), new IndexRange(2, 2))); + checkJobVertexInputInfo( + 7, rightInputInfos, rightTargetConsumedSubpartitionGroups, vertexInputs); + } + + @Test + void testComputeAllSkewedInputNotExistIntraInputKeyCorrelation() { + testComputeAllSkewedInputNotExistIntraInputKeyCorrelation(1); + testComputeAllSkewedInputNotExistIntraInputKeyCorrelation(10); + } + + void testComputeAllSkewedInputNotExistIntraInputKeyCorrelation(int numInputInfos) { + AllToAllVertexInputInfoComputer computer = createAllToAllVertexInputInfoComputer(); + List<BlockingInputInfo> inputInfos = new ArrayList<>(); + List<BlockingInputInfo> leftInputInfos = + createBlockingInputInfos(1, numInputInfos, 2, false, true, List.of(1)); + List<BlockingInputInfo> rightInputInfos = + createBlockingInputInfos(2, numInputInfos, 2, false, true, List.of(1)); + inputInfos.addAll(leftInputInfos); + inputInfos.addAll(rightInputInfos); + Map<IntermediateDataSetID, JobVertexInputInfo> vertexInputs = + computer.compute(new JobVertexID(), inputInfos, 2, 1, 2); Review Comment: Could you test more parallelism/minParallelism/maxParallelism combinations? ########## flink-runtime/src/test/java/org/apache/flink/runtime/scheduler/adaptivebatch/util/AllToAllVertexInputInfoComputerTest.java: ########## @@ -0,0 +1,313 @@ +/* + * 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.adaptivebatch.util; + +import org.apache.flink.runtime.executiongraph.IndexRange; +import org.apache.flink.runtime.executiongraph.JobVertexInputInfo; +import org.apache.flink.runtime.jobgraph.IntermediateDataSetID; +import org.apache.flink.runtime.jobgraph.JobVertexID; +import org.apache.flink.runtime.scheduler.adaptivebatch.BlockingInputInfo; +import org.apache.flink.runtime.scheduler.adaptivebatch.VertexInputInfoComputerTestUtil; + +import org.junit.jupiter.api.Test; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import static org.apache.flink.runtime.scheduler.adaptivebatch.VertexInputInfoComputerTestUtil.checkJobVertexInputInfo; + +/** Tests for {@link AllToAllVertexInputInfoComputer}. */ +class AllToAllVertexInputInfoComputerTest { + + @Test + void testComputeAllInputExistIntraInputKeyCorrelation() { + testComputeAllInputExistIntraInputKeyCorrelation(1); + testComputeAllInputExistIntraInputKeyCorrelation(10); + } + + void testComputeAllInputExistIntraInputKeyCorrelation(int numInputInfos) { + AllToAllVertexInputInfoComputer computer = createAllToAllVertexInputInfoComputer(); + List<BlockingInputInfo> inputInfos = new ArrayList<>(); + List<BlockingInputInfo> leftInputInfos = + createBlockingInputInfos(1, numInputInfos, 10, true, true, List.of(0)); + List<BlockingInputInfo> rightInputInfos = + createBlockingInputInfos(2, numInputInfos, 10, true, true, List.of()); + inputInfos.addAll(leftInputInfos); + inputInfos.addAll(rightInputInfos); + Map<IntermediateDataSetID, JobVertexInputInfo> vertexInputs = + computer.compute(new JobVertexID(), inputInfos, 10, 1, 10); + List<Map<IndexRange, IndexRange>> targetConsumedSubpartitionGroups = + List.of( + Map.of(new IndexRange(0, 9), new IndexRange(0, 0)), + Map.of(new IndexRange(0, 9), new IndexRange(1, 1)), + Map.of(new IndexRange(0, 9), new IndexRange(2, 2))); + checkJobVertexInputInfo(3, inputInfos, targetConsumedSubpartitionGroups, vertexInputs); + } + + @Test + void testComputeOneSkewedInputNotExistIntraInputKeyCorrelation() { Review Comment: -> testComputeSkewedInputWithoutIntraInputKeyCorrelation ########## flink-runtime/src/test/java/org/apache/flink/runtime/scheduler/adaptivebatch/util/PointwiseVertexInputInfoComputerTest.java: ########## @@ -0,0 +1,124 @@ +/* + * 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.adaptivebatch.util; + +import org.apache.flink.runtime.executiongraph.IndexRange; +import org.apache.flink.runtime.executiongraph.JobVertexInputInfo; +import org.apache.flink.runtime.jobgraph.IntermediateDataSetID; +import org.apache.flink.runtime.scheduler.adaptivebatch.BlockingInputInfo; +import org.apache.flink.runtime.scheduler.adaptivebatch.VertexInputInfoComputerTestUtil; + +import org.junit.jupiter.api.Test; + +import java.util.List; +import java.util.Map; + +import static org.apache.flink.runtime.scheduler.adaptivebatch.VertexInputInfoComputerTestUtil.checkJobVertexInputInfo; + +/** Tests for {@link PointwiseVertexInputInfoComputer}. */ +class PointwiseVertexInputInfoComputerTest { + + @Test + void testComputePointwiseInputWithoutSkewed() { Review Comment: -> `testComputePointwiseInputWithoutSkew` or simply `testComputePointwiseInput` ########## flink-runtime/src/test/java/org/apache/flink/runtime/scheduler/adaptivebatch/util/AllToAllVertexInputInfoComputerTest.java: ########## @@ -0,0 +1,313 @@ +/* + * 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.adaptivebatch.util; + +import org.apache.flink.runtime.executiongraph.IndexRange; +import org.apache.flink.runtime.executiongraph.JobVertexInputInfo; +import org.apache.flink.runtime.jobgraph.IntermediateDataSetID; +import org.apache.flink.runtime.jobgraph.JobVertexID; +import org.apache.flink.runtime.scheduler.adaptivebatch.BlockingInputInfo; +import org.apache.flink.runtime.scheduler.adaptivebatch.VertexInputInfoComputerTestUtil; + +import org.junit.jupiter.api.Test; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import static org.apache.flink.runtime.scheduler.adaptivebatch.VertexInputInfoComputerTestUtil.checkJobVertexInputInfo; + +/** Tests for {@link AllToAllVertexInputInfoComputer}. */ +class AllToAllVertexInputInfoComputerTest { + + @Test + void testComputeAllInputExistIntraInputKeyCorrelation() { Review Comment: And could you add a case to test `normal` ALL-to-ALL inputs without skews? ########## flink-runtime/src/test/java/org/apache/flink/runtime/scheduler/adaptivebatch/util/AllToAllVertexInputInfoComputerTest.java: ########## @@ -0,0 +1,313 @@ +/* + * 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.adaptivebatch.util; + +import org.apache.flink.runtime.executiongraph.IndexRange; +import org.apache.flink.runtime.executiongraph.JobVertexInputInfo; +import org.apache.flink.runtime.jobgraph.IntermediateDataSetID; +import org.apache.flink.runtime.jobgraph.JobVertexID; +import org.apache.flink.runtime.scheduler.adaptivebatch.BlockingInputInfo; +import org.apache.flink.runtime.scheduler.adaptivebatch.VertexInputInfoComputerTestUtil; + +import org.junit.jupiter.api.Test; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import static org.apache.flink.runtime.scheduler.adaptivebatch.VertexInputInfoComputerTestUtil.checkJobVertexInputInfo; + +/** Tests for {@link AllToAllVertexInputInfoComputer}. */ +class AllToAllVertexInputInfoComputerTest { + + @Test + void testComputeAllInputExistIntraInputKeyCorrelation() { + testComputeAllInputExistIntraInputKeyCorrelation(1); + testComputeAllInputExistIntraInputKeyCorrelation(10); + } + + void testComputeAllInputExistIntraInputKeyCorrelation(int numInputInfos) { + AllToAllVertexInputInfoComputer computer = createAllToAllVertexInputInfoComputer(); + List<BlockingInputInfo> inputInfos = new ArrayList<>(); + List<BlockingInputInfo> leftInputInfos = + createBlockingInputInfos(1, numInputInfos, 10, true, true, List.of(0)); + List<BlockingInputInfo> rightInputInfos = + createBlockingInputInfos(2, numInputInfos, 10, true, true, List.of()); + inputInfos.addAll(leftInputInfos); + inputInfos.addAll(rightInputInfos); + Map<IntermediateDataSetID, JobVertexInputInfo> vertexInputs = + computer.compute(new JobVertexID(), inputInfos, 10, 1, 10); + List<Map<IndexRange, IndexRange>> targetConsumedSubpartitionGroups = + List.of( + Map.of(new IndexRange(0, 9), new IndexRange(0, 0)), + Map.of(new IndexRange(0, 9), new IndexRange(1, 1)), + Map.of(new IndexRange(0, 9), new IndexRange(2, 2))); + checkJobVertexInputInfo(3, inputInfos, targetConsumedSubpartitionGroups, vertexInputs); + } + + @Test + void testComputeOneSkewedInputNotExistIntraInputKeyCorrelation() { + testComputeOneSkewedInputNotExistIntraInputKeyCorrelation(1); + testComputeOneSkewedInputNotExistIntraInputKeyCorrelation(10); + } + + void testComputeOneSkewedInputNotExistIntraInputKeyCorrelation(int numInputInfos) { + AllToAllVertexInputInfoComputer computer = createAllToAllVertexInputInfoComputer(); + List<BlockingInputInfo> inputInfos = new ArrayList<>(); + List<BlockingInputInfo> leftInputInfos = + createBlockingInputInfos(1, numInputInfos, 10, false, true, List.of(0)); + List<BlockingInputInfo> rightInputInfos = + createBlockingInputInfos(2, numInputInfos, 10, true, true, List.of()); + inputInfos.addAll(leftInputInfos); + inputInfos.addAll(rightInputInfos); + Map<IntermediateDataSetID, JobVertexInputInfo> vertexInputs = + computer.compute(new JobVertexID(), inputInfos, 10, 1, 10); + List<Map<IndexRange, IndexRange>> leftTargetConsumedSubpartitionGroups = + List.of( + Map.of(new IndexRange(0, 1), new IndexRange(0, 0)), + Map.of(new IndexRange(2, 3), new IndexRange(0, 0)), + Map.of(new IndexRange(4, 5), new IndexRange(0, 0)), + Map.of(new IndexRange(6, 7), new IndexRange(0, 0)), + Map.of(new IndexRange(8, 9), new IndexRange(0, 0)), + Map.of(new IndexRange(0, 9), new IndexRange(1, 1)), + Map.of(new IndexRange(0, 9), new IndexRange(2, 2))); + checkJobVertexInputInfo( + 7, leftInputInfos, leftTargetConsumedSubpartitionGroups, vertexInputs); + List<Map<IndexRange, IndexRange>> rightTargetConsumedSubpartitionGroups = + List.of( + Map.of(new IndexRange(0, 9), new IndexRange(0, 0)), + Map.of(new IndexRange(0, 9), new IndexRange(0, 0)), + Map.of(new IndexRange(0, 9), new IndexRange(0, 0)), + Map.of(new IndexRange(0, 9), new IndexRange(0, 0)), + Map.of(new IndexRange(0, 9), new IndexRange(0, 0)), + Map.of(new IndexRange(0, 9), new IndexRange(1, 1)), + Map.of(new IndexRange(0, 9), new IndexRange(2, 2))); + checkJobVertexInputInfo( + 7, rightInputInfos, rightTargetConsumedSubpartitionGroups, vertexInputs); + } + + @Test + void testComputeAllSkewedInputNotExistIntraInputKeyCorrelation() { + testComputeAllSkewedInputNotExistIntraInputKeyCorrelation(1); + testComputeAllSkewedInputNotExistIntraInputKeyCorrelation(10); + } + + void testComputeAllSkewedInputNotExistIntraInputKeyCorrelation(int numInputInfos) { + AllToAllVertexInputInfoComputer computer = createAllToAllVertexInputInfoComputer(); + List<BlockingInputInfo> inputInfos = new ArrayList<>(); + List<BlockingInputInfo> leftInputInfos = + createBlockingInputInfos(1, numInputInfos, 2, false, true, List.of(1)); + List<BlockingInputInfo> rightInputInfos = + createBlockingInputInfos(2, numInputInfos, 2, false, true, List.of(1)); + inputInfos.addAll(leftInputInfos); + inputInfos.addAll(rightInputInfos); + Map<IntermediateDataSetID, JobVertexInputInfo> vertexInputs = + computer.compute(new JobVertexID(), inputInfos, 2, 1, 2); + + List<Map<IndexRange, IndexRange>> leftTargetConsumedSubpartitionGroups = + List.of( + Map.of( + new IndexRange(0, 0), + new IndexRange(1, 1), + new IndexRange(0, 1), + new IndexRange(0, 0)), + Map.of( + new IndexRange(1, 1), + new IndexRange(1, 1), + new IndexRange(0, 1), + new IndexRange(2, 2))); + + List<Map<IndexRange, IndexRange>> rightTargetConsumedSubpartitionGroups = + List.of( + Map.of(new IndexRange(0, 1), new IndexRange(0, 1)), + Map.of(new IndexRange(0, 1), new IndexRange(1, 2))); Review Comment: How about to use some expected results which can better reflects the result? e.g. the expected data size that each will consume from each input ########## flink-runtime/src/test/java/org/apache/flink/runtime/scheduler/adaptivebatch/util/AllToAllVertexInputInfoComputerTest.java: ########## @@ -0,0 +1,313 @@ +/* + * 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.adaptivebatch.util; + +import org.apache.flink.runtime.executiongraph.IndexRange; +import org.apache.flink.runtime.executiongraph.JobVertexInputInfo; +import org.apache.flink.runtime.jobgraph.IntermediateDataSetID; +import org.apache.flink.runtime.jobgraph.JobVertexID; +import org.apache.flink.runtime.scheduler.adaptivebatch.BlockingInputInfo; +import org.apache.flink.runtime.scheduler.adaptivebatch.VertexInputInfoComputerTestUtil; + +import org.junit.jupiter.api.Test; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import static org.apache.flink.runtime.scheduler.adaptivebatch.VertexInputInfoComputerTestUtil.checkJobVertexInputInfo; + +/** Tests for {@link AllToAllVertexInputInfoComputer}. */ +class AllToAllVertexInputInfoComputerTest { + + @Test + void testComputeAllInputExistIntraInputKeyCorrelation() { + testComputeAllInputExistIntraInputKeyCorrelation(1); + testComputeAllInputExistIntraInputKeyCorrelation(10); + } + + void testComputeAllInputExistIntraInputKeyCorrelation(int numInputInfos) { + AllToAllVertexInputInfoComputer computer = createAllToAllVertexInputInfoComputer(); + List<BlockingInputInfo> inputInfos = new ArrayList<>(); + List<BlockingInputInfo> leftInputInfos = + createBlockingInputInfos(1, numInputInfos, 10, true, true, List.of(0)); + List<BlockingInputInfo> rightInputInfos = + createBlockingInputInfos(2, numInputInfos, 10, true, true, List.of()); + inputInfos.addAll(leftInputInfos); + inputInfos.addAll(rightInputInfos); + Map<IntermediateDataSetID, JobVertexInputInfo> vertexInputs = + computer.compute(new JobVertexID(), inputInfos, 10, 1, 10); + List<Map<IndexRange, IndexRange>> targetConsumedSubpartitionGroups = + List.of( + Map.of(new IndexRange(0, 9), new IndexRange(0, 0)), + Map.of(new IndexRange(0, 9), new IndexRange(1, 1)), + Map.of(new IndexRange(0, 9), new IndexRange(2, 2))); + checkJobVertexInputInfo(3, inputInfos, targetConsumedSubpartitionGroups, vertexInputs); + } + + @Test + void testComputeOneSkewedInputNotExistIntraInputKeyCorrelation() { + testComputeOneSkewedInputNotExistIntraInputKeyCorrelation(1); + testComputeOneSkewedInputNotExistIntraInputKeyCorrelation(10); + } + + void testComputeOneSkewedInputNotExistIntraInputKeyCorrelation(int numInputInfos) { + AllToAllVertexInputInfoComputer computer = createAllToAllVertexInputInfoComputer(); + List<BlockingInputInfo> inputInfos = new ArrayList<>(); + List<BlockingInputInfo> leftInputInfos = + createBlockingInputInfos(1, numInputInfos, 10, false, true, List.of(0)); + List<BlockingInputInfo> rightInputInfos = + createBlockingInputInfos(2, numInputInfos, 10, true, true, List.of()); + inputInfos.addAll(leftInputInfos); + inputInfos.addAll(rightInputInfos); + Map<IntermediateDataSetID, JobVertexInputInfo> vertexInputs = + computer.compute(new JobVertexID(), inputInfos, 10, 1, 10); + List<Map<IndexRange, IndexRange>> leftTargetConsumedSubpartitionGroups = + List.of( + Map.of(new IndexRange(0, 1), new IndexRange(0, 0)), + Map.of(new IndexRange(2, 3), new IndexRange(0, 0)), + Map.of(new IndexRange(4, 5), new IndexRange(0, 0)), + Map.of(new IndexRange(6, 7), new IndexRange(0, 0)), + Map.of(new IndexRange(8, 9), new IndexRange(0, 0)), + Map.of(new IndexRange(0, 9), new IndexRange(1, 1)), + Map.of(new IndexRange(0, 9), new IndexRange(2, 2))); + checkJobVertexInputInfo( + 7, leftInputInfos, leftTargetConsumedSubpartitionGroups, vertexInputs); + List<Map<IndexRange, IndexRange>> rightTargetConsumedSubpartitionGroups = + List.of( + Map.of(new IndexRange(0, 9), new IndexRange(0, 0)), + Map.of(new IndexRange(0, 9), new IndexRange(0, 0)), + Map.of(new IndexRange(0, 9), new IndexRange(0, 0)), + Map.of(new IndexRange(0, 9), new IndexRange(0, 0)), + Map.of(new IndexRange(0, 9), new IndexRange(0, 0)), + Map.of(new IndexRange(0, 9), new IndexRange(1, 1)), + Map.of(new IndexRange(0, 9), new IndexRange(2, 2))); + checkJobVertexInputInfo( + 7, rightInputInfos, rightTargetConsumedSubpartitionGroups, vertexInputs); + } + + @Test + void testComputeAllSkewedInputNotExistIntraInputKeyCorrelation() { Review Comment: -> testComputeMultipleSkewedInputsWithoutIntraInputKeyCorrelation -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
