pnowojski commented on a change in pull request #5:
URL: https://github.com/apache/flink-benchmarks/pull/5#discussion_r514970292



##########
File path: 
src/main/java/org/apache/flink/benchmark/SortingBoundedInputBenchmarks.java
##########
@@ -0,0 +1,418 @@
+/*
+ * 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.benchmark;
+
+import org.apache.flink.api.common.RuntimeExecutionMode;
+import org.apache.flink.api.common.typeinfo.BasicTypeInfo;
+import org.apache.flink.api.common.typeinfo.PrimitiveArrayTypeInfo;
+import org.apache.flink.api.java.tuple.Tuple2;
+import org.apache.flink.api.java.typeutils.TupleTypeInfo;
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.configuration.ExecutionOptions;
+import org.apache.flink.configuration.MemorySize;
+import org.apache.flink.streaming.api.datastream.DataStream;
+import org.apache.flink.streaming.api.datastream.DataStreamSource;
+import org.apache.flink.streaming.api.datastream.KeyedStream;
+import org.apache.flink.streaming.api.datastream.SingleOutputStreamOperator;
+import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
+import org.apache.flink.streaming.api.functions.sink.DiscardingSink;
+import org.apache.flink.streaming.api.operators.AbstractStreamOperator;
+import org.apache.flink.streaming.api.operators.AbstractStreamOperatorV2;
+import org.apache.flink.streaming.api.operators.BoundedMultiInput;
+import org.apache.flink.streaming.api.operators.BoundedOneInput;
+import org.apache.flink.streaming.api.operators.ChainingStrategy;
+import org.apache.flink.streaming.api.operators.Input;
+import org.apache.flink.streaming.api.operators.MultipleInputStreamOperator;
+import org.apache.flink.streaming.api.operators.OneInputStreamOperator;
+import org.apache.flink.streaming.api.operators.StreamOperator;
+import org.apache.flink.streaming.api.operators.StreamOperatorFactory;
+import org.apache.flink.streaming.api.operators.StreamOperatorParameters;
+import org.apache.flink.streaming.api.operators.TwoInputStreamOperator;
+import 
org.apache.flink.streaming.api.transformations.KeyedMultipleInputTransformation;
+import org.apache.flink.streaming.runtime.streamrecord.LatencyMarker;
+import org.apache.flink.streaming.runtime.streamrecord.StreamRecord;
+import org.apache.flink.util.SplittableIterator;
+
+import org.junit.Assert;
+import org.openjdk.jmh.annotations.Benchmark;
+import org.openjdk.jmh.annotations.OperationsPerInvocation;
+import org.openjdk.jmh.annotations.Param;
+import org.openjdk.jmh.annotations.State;
+import org.openjdk.jmh.runner.Runner;
+import org.openjdk.jmh.runner.RunnerException;
+import org.openjdk.jmh.runner.options.Options;
+import org.openjdk.jmh.runner.options.OptionsBuilder;
+import org.openjdk.jmh.runner.options.VerboseMode;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Objects;
+import java.util.Random;
+import java.util.Set;
+import java.util.function.Consumer;
+
+import static org.openjdk.jmh.annotations.Scope.Thread;
+
+/**
+ * An end to end test for sorted inputs for a keyed operator with bounded 
inputs.
+ */
+public class SortingBoundedInputBenchmarks extends BenchmarkBase {
+
+       protected static final int RECORDS_PER_INVOCATION = 900_000;
+
+       public static void main(String[] args) throws RunnerException {
+               Options options = new OptionsBuilder()
+                               .verbosity(VerboseMode.NORMAL)
+                               .include(".*" + 
SortingBoundedInputBenchmarks.class.getCanonicalName() + ".*")
+                               .build();
+
+               new Runner(options).run();
+       }
+
+       @State(Thread)
+       public static class SortingInputContext extends FlinkEnvironmentContext 
{
+               @Param({"true", "false"})
+               public boolean useSingleKeyStateBackend;

Review comment:
       Hmmm, do we need to compare it against non single key state backends 
(`useSingleKeyStateBackend = false`)? (We already have benchmarks for 
one/two/multiple input operators) ?

##########
File path: 
src/main/java/org/apache/flink/benchmark/SortingBoundedInputBenchmarks.java
##########
@@ -0,0 +1,418 @@
+/*
+ * 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.benchmark;
+
+import org.apache.flink.api.common.RuntimeExecutionMode;
+import org.apache.flink.api.common.typeinfo.BasicTypeInfo;
+import org.apache.flink.api.common.typeinfo.PrimitiveArrayTypeInfo;
+import org.apache.flink.api.java.tuple.Tuple2;
+import org.apache.flink.api.java.typeutils.TupleTypeInfo;
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.configuration.ExecutionOptions;
+import org.apache.flink.configuration.MemorySize;
+import org.apache.flink.streaming.api.datastream.DataStream;
+import org.apache.flink.streaming.api.datastream.DataStreamSource;
+import org.apache.flink.streaming.api.datastream.KeyedStream;
+import org.apache.flink.streaming.api.datastream.SingleOutputStreamOperator;
+import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
+import org.apache.flink.streaming.api.functions.sink.DiscardingSink;
+import org.apache.flink.streaming.api.operators.AbstractStreamOperator;
+import org.apache.flink.streaming.api.operators.AbstractStreamOperatorV2;
+import org.apache.flink.streaming.api.operators.BoundedMultiInput;
+import org.apache.flink.streaming.api.operators.BoundedOneInput;
+import org.apache.flink.streaming.api.operators.ChainingStrategy;
+import org.apache.flink.streaming.api.operators.Input;
+import org.apache.flink.streaming.api.operators.MultipleInputStreamOperator;
+import org.apache.flink.streaming.api.operators.OneInputStreamOperator;
+import org.apache.flink.streaming.api.operators.StreamOperator;
+import org.apache.flink.streaming.api.operators.StreamOperatorFactory;
+import org.apache.flink.streaming.api.operators.StreamOperatorParameters;
+import org.apache.flink.streaming.api.operators.TwoInputStreamOperator;
+import 
org.apache.flink.streaming.api.transformations.KeyedMultipleInputTransformation;
+import org.apache.flink.streaming.runtime.streamrecord.LatencyMarker;
+import org.apache.flink.streaming.runtime.streamrecord.StreamRecord;
+import org.apache.flink.util.SplittableIterator;
+
+import org.junit.Assert;
+import org.openjdk.jmh.annotations.Benchmark;
+import org.openjdk.jmh.annotations.OperationsPerInvocation;
+import org.openjdk.jmh.annotations.Param;
+import org.openjdk.jmh.annotations.State;
+import org.openjdk.jmh.runner.Runner;
+import org.openjdk.jmh.runner.RunnerException;
+import org.openjdk.jmh.runner.options.Options;
+import org.openjdk.jmh.runner.options.OptionsBuilder;
+import org.openjdk.jmh.runner.options.VerboseMode;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Objects;
+import java.util.Random;
+import java.util.Set;
+import java.util.function.Consumer;
+
+import static org.openjdk.jmh.annotations.Scope.Thread;
+
+/**
+ * An end to end test for sorted inputs for a keyed operator with bounded 
inputs.
+ */
+public class SortingBoundedInputBenchmarks extends BenchmarkBase {
+
+       protected static final int RECORDS_PER_INVOCATION = 900_000;
+
+       public static void main(String[] args) throws RunnerException {
+               Options options = new OptionsBuilder()
+                               .verbosity(VerboseMode.NORMAL)
+                               .include(".*" + 
SortingBoundedInputBenchmarks.class.getCanonicalName() + ".*")
+                               .build();
+
+               new Runner(options).run();
+       }
+
+       @State(Thread)
+       public static class SortingInputContext extends FlinkEnvironmentContext 
{
+               @Param({"true", "false"})
+               public boolean useSingleKeyStateBackend;
+
+               @Override
+               protected Configuration createConfiguration() {
+                       Configuration configuration = 
super.createConfiguration();
+                       
configuration.set(ExecutionOptions.USE_BATCH_STATE_BACKEND, 
useSingleKeyStateBackend);
+                       configuration.set(ExecutionOptions.RUNTIME_MODE, 
RuntimeExecutionMode.BATCH);
+                       return configuration;
+               }
+       }
+
+       @Benchmark
+       @OperationsPerInvocation(value = RECORDS_PER_INVOCATION)
+       public void oneInputOperator(SortingInputContext context) {
+               StreamExecutionEnvironment env = context.env;
+
+               DataStreamSource<Tuple2<Integer, byte[]>> elements = 
env.fromParallelCollection(
+                       new InputGenerator(RECORDS_PER_INVOCATION),
+                       new TupleTypeInfo<>(BasicTypeInfo.INT_TYPE_INFO, 
PrimitiveArrayTypeInfo.BYTE_PRIMITIVE_ARRAY_TYPE_INFO)
+               );
+
+               SingleOutputStreamOperator<Long> counts = elements
+                       .keyBy(element -> element.f0)
+                       .transform(
+                               "Asserting operator",
+                               BasicTypeInfo.LONG_TYPE_INFO,
+                               new AssertingOperator()
+                       );
+
+               counts.addSink(new DiscardingSink<>());

Review comment:
       aren't we missing `env.execute()`? The benchmark results I observed are 
suspiciously high
   ```
   Iteration   1: 125200.947 ops/ms
   Iteration   2: 164695.613 ops/ms
   Iteration   3: 133524.562 ops/ms
   ```
   This can also explain resource leaks and stability problems.




----------------------------------------------------------------
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:
[email protected]


Reply via email to