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

 ##########
 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:
   Did you introduce this `volatile boolean` in order to stop benchmarks? 
Couldn't you use `EndOfPartitionEvent` instead to do this? Basically when you 
prepare an input in the benchmarks, just emit `EndOfPartitionEvent` at the end. 
When this event gets to the receiving operator, it should interrupt processing 
loops. The only issue might be that it will be impossible to restart the input 
without recreating it, but overhead of constructing the 
`StreamTwoInputProcessor` and `inputChannels` at the start of every benchmark 
iteration should be negligible. While on the other hand, checking `volatile 
boolean` once per record might affect results.

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

Reply via email to