ferenc-csaky commented on code in PR #27446:
URL: https://github.com/apache/flink/pull/27446#discussion_r2758380079
##########
flink-core/src/main/java/org/apache/flink/configuration/NettyShuffleEnvironmentOptions.java:
##########
@@ -325,6 +325,34 @@ public enum CompressionCodec {
code(NETWORK_REQUEST_BACKOFF_MAX.key()))
.build());
+ /** Whether to improve the rebalance and rescale partitioners to adaptive
partition. */
+ @Documentation.Section(Documentation.Sections.ALL_TASK_MANAGER_NETWORK)
+ public static final ConfigOption<Boolean> ADAPTIVE_PARTITIONER_ENABLED =
+ key("taskmanager.network.adaptive-partitioner.enabled")
+ .booleanType()
+ .defaultValue(false)
+ .withDescription(
+ "Whether to enable adaptive partitioner feature
for rescale and rebalance partitioners based on the loading of the downstream
tasks.");
Review Comment:
nit: "loading" -> "load"
##########
flink-core/src/main/java/org/apache/flink/configuration/NettyShuffleEnvironmentOptions.java:
##########
@@ -325,6 +325,34 @@ public enum CompressionCodec {
code(NETWORK_REQUEST_BACKOFF_MAX.key()))
.build());
+ /** Whether to improve the rebalance and rescale partitioners to adaptive
partition. */
+ @Documentation.Section(Documentation.Sections.ALL_TASK_MANAGER_NETWORK)
+ public static final ConfigOption<Boolean> ADAPTIVE_PARTITIONER_ENABLED =
+ key("taskmanager.network.adaptive-partitioner.enabled")
+ .booleanType()
+ .defaultValue(false)
+ .withDescription(
+ "Whether to enable adaptive partitioner feature
for rescale and rebalance partitioners based on the loading of the downstream
tasks.");
+
+ /**
+ * Maximum number of channels to traverse when looking for the idlest
channel for rescale and
+ * rebalance partitioners when {@link #ADAPTIVE_PARTITIONER_ENABLED} is
true.
+ */
+ @Documentation.Section(Documentation.Sections.ALL_TASK_MANAGER_NETWORK)
+ public static final ConfigOption<Integer>
ADAPTIVE_PARTITIONER_MAX_TRAVERSE_SIZE =
+ key("taskmanager.network.adaptive-partitioner.max-traverse-size")
+ .intType()
+ .defaultValue(4)
+ .withDescription(
+ Description.builder()
+ .text(
+ "Maximum number of channels to
traverse when looking for the idlest channel for rescale and rebalance
partitioners when %s is enabled.",
Review Comment:
nit: "idlest" -> "most idle" (or "least busy", "least loaded")
##########
flink-runtime/src/main/java/org/apache/flink/runtime/io/network/partition/BufferWritingResultPartition.java:
##########
@@ -65,7 +65,7 @@ public abstract class BufferWritingResultPartition extends
ResultPartition {
private TimerGauge hardBackPressuredTimeMsPerSecond = new TimerGauge();
- private long totalWrittenBytes;
+ private final long[] subpartitionWrittenBytes;
Review Comment:
nit: maybe name it `writtenBytesPerSubpartition`
##########
flink-runtime/src/main/java/org/apache/flink/runtime/io/network/api/writer/RecordWriterBuilder.java:
##########
@@ -44,11 +51,29 @@ public RecordWriterBuilder<T> setTaskName(String taskName) {
return this;
}
+ public RecordWriterBuilder<T> setEnabledAdaptivePartitioner(
+ boolean enabledAdaptivePartitioner) {
+ this.enabledAdaptivePartitioner = enabledAdaptivePartitioner;
+ return this;
+ }
+
+ public RecordWriterBuilder<T> setMaxTraverseSize(int maxTraverseSize) {
+ Preconditions.checkArgument(
Review Comment:
Validating this config here seems a bit off to me. A setter should be dead
simple, I'd rather do this right after we get it from the config obj in
`StreamTask`, or in the `build()` method instead.
Also, we have `IllegalConfigurationException` that should be thrown in these
situations, and `ConfigurationParserUtils.checkConfigParameter(...)` function
wraps pretty much this exact logic just uses that mentioned exception instead.
##########
flink-runtime/src/main/java/org/apache/flink/runtime/io/network/api/writer/AdaptiveLoadBasedRecordWriter.java:
##########
@@ -0,0 +1,107 @@
+/*
+ * 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.io.network.api.writer;
+
+import org.apache.flink.annotation.Internal;
+import org.apache.flink.annotation.VisibleForTesting;
+import org.apache.flink.core.io.IOReadableWritable;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+
+/** A record writer based on load of downstream tasks. */
+@Internal
+public final class AdaptiveLoadBasedRecordWriter<T extends IOReadableWritable>
+ extends RecordWriter<T> {
+
+ private final int maxTraverseSize;
+
+ private int currentChannel = -1;
+
+ private final int numberOfSubpartitions;
Review Comment:
nit: I'd switch these 2 fields, grouping `private final` fields first, and
only start non-finals afterwards.
--
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]