sunhaibotb commented on a change in pull request #8124: [FLINK-11877] Implement the runtime handling of the InputSelectable interface URL: https://github.com/apache/flink/pull/8124#discussion_r275609702
########## File path: flink-streaming-java/src/test/java/org/apache/flink/streaming/runtime/io/benchmark/StreamTaskNonSelectableInputThroughputBenchmark.java ########## @@ -0,0 +1,122 @@ +/* + * 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.streaming.runtime.io.benchmark; + +import org.apache.flink.runtime.io.network.partition.consumer.IterableInputChannel; +import org.apache.flink.streaming.runtime.io.StreamTwoInputProcessor; +import org.apache.flink.streaming.runtime.io.benchmark.StreamTaskInputBenchmarkEnvironment.ProcessorAndChannels; + +import java.io.IOException; +import java.util.List; + +/** + * Task-input (non-selectable) throughput benchmarks executed by the external + * <a href="https://github.com/dataArtisans/flink-benchmarks">flink-benchmarks</a> project. + */ +public class StreamTaskNonSelectableInputThroughputBenchmark extends StreamTaskInputThroughputBenchmarkBase { + + public void setUp(int numInputGates, int numChannelsPerGate, long numRecordsPerChannel) throws Exception { + setUp( + numInputGates, numInputGates, + numChannelsPerGate, numChannelsPerGate, + numRecordsPerChannel, numRecordsPerChannel, + new SummingLongStreamOperator()); + } + + @Override + protected AbstractTaskInputProcessorThread createProcessorThread( + int numInputGates1, + int numInputGates2, + int numChannels1PerGate, + int numChannels2PerGate, + long numRecords1PerChannel, + long numRecords2PerChannel, + long inputValue1, + long inputValue2, + SummingLongStreamOperator streamOperator) throws IOException { + + ProcessorAndChannels<StreamTwoInputProcessor<?, ?>, IterableInputChannel> processorAndChannels = + environment.createTwoInputProcessor( + numInputGates1, + numInputGates2, + numChannels1PerGate, + numChannels2PerGate, + numRecords1PerChannel, + numRecords2PerChannel, + 1, + 2, + streamOperator); + + return new StreamTwoInputProcessorThread( + processorAndChannels.processor(), + processorAndChannels.channels(), + streamOperator); + } + + // ------------------------------------------------------------------------ + // Utilities + // ------------------------------------------------------------------------ + + private static class StreamTwoInputProcessorThread extends AbstractTaskInputProcessorThread { + + private final StreamTwoInputProcessor<?, ?> inputProcessor; + + private final SummingLongStreamOperator streamOperator; + + private volatile boolean continuousProcessing = true; Review comment: I think the current implementation is better because it avoids the impact of benchmark's own code as much as possible. Although the overhead of constructing `StreamTwoInputProcessor` and `inputChannels` with using `EndOfPartitionEvent` can be balanced to some extent by increasing the number of processed records, but it also will increase the time of benchmark. Using `EndOfPartitionEvent` doesn't seem to have any other benefits except that the code looks more beautiful. (The previous version is the use of `EndOfPartitionEvent` and I change it to the currently implementation.) ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services