[
https://issues.apache.org/jira/browse/FLINK-3477?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15369670#comment-15369670
]
ASF GitHub Bot commented on FLINK-3477:
---------------------------------------
Github user ggevay commented on a diff in the pull request:
https://github.com/apache/flink/pull/1517#discussion_r70182809
--- Diff:
flink-tests/src/test/java/org/apache/flink/test/manual/ReducePerformance.java
---
@@ -0,0 +1,237 @@
+/*
+ * 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.test.manual;
+
+import org.apache.flink.api.common.functions.ReduceFunction;
+import
org.apache.flink.api.common.operators.base.ReduceOperatorBase.CombineHint;
+import org.apache.flink.api.common.typeinfo.TypeInformation;
+import org.apache.flink.api.java.DataSet;
+import org.apache.flink.api.java.ExecutionEnvironment;
+import org.apache.flink.api.java.tuple.Tuple2;
+import org.apache.flink.api.java.typeutils.TupleTypeInfo;
+import org.apache.flink.util.SplittableIterator;
+
+import java.io.Serializable;
+import java.util.Iterator;
+import java.util.Random;
+
+public class ReducePerformance {
+
+ public static void main(String[] args) throws Exception {
+
+ final int numElements = 40_000_000;
+ final int keyRange = 4_000_000;
+
+ // warm up JIT
+ testReducePerformance(new TupleIntIntIterator(1000),
+ TupleTypeInfo.<Tuple2<Integer,
Integer>>getBasicTupleTypeInfo(Integer.class, Integer.class),
+ CombineHint.SORT, 10000, false);
+
+ testReducePerformance(new TupleIntIntIterator(1000),
+ TupleTypeInfo.<Tuple2<Integer,
Integer>>getBasicTupleTypeInfo(Integer.class, Integer.class),
+ CombineHint.HASH, 10000, false);
+
+ // TupleIntIntIterator
+ testReducePerformance(new TupleIntIntIterator(keyRange),
+ TupleTypeInfo.<Tuple2<Integer,
Integer>>getBasicTupleTypeInfo(Integer.class, Integer.class),
+ CombineHint.SORT, numElements, true);
+
+ testReducePerformance(new TupleIntIntIterator(keyRange),
+ TupleTypeInfo.<Tuple2<Integer,
Integer>>getBasicTupleTypeInfo(Integer.class, Integer.class),
+ CombineHint.HASH, numElements, true);
+
+ // TupleStringIntIterator
+ testReducePerformance(new TupleStringIntIterator(keyRange),
+ TupleTypeInfo.<Tuple2<String,
Integer>>getBasicTupleTypeInfo(String.class, Integer.class),
+ CombineHint.SORT, numElements, true);
+
+ testReducePerformance(new TupleStringIntIterator(keyRange),
+ TupleTypeInfo.<Tuple2<String,
Integer>>getBasicTupleTypeInfo(String.class, Integer.class),
+ CombineHint.HASH, numElements, true);
+ }
+
+ private static <T, B extends CopyableIterator<T>> void
testReducePerformance
+ (B iterator, TypeInformation<T> typeInfo, CombineHint hint, int
numRecords, boolean print) throws Exception {
+
+ ExecutionEnvironment env =
ExecutionEnvironment.getExecutionEnvironment();
+ //env.getConfig().enableObjectReuse();
--- End diff --
615f6a642e30edec8fb98c3319d37983c97d971a
> Add hash-based combine strategy for ReduceFunction
> --------------------------------------------------
>
> Key: FLINK-3477
> URL: https://issues.apache.org/jira/browse/FLINK-3477
> Project: Flink
> Issue Type: Sub-task
> Components: Local Runtime
> Reporter: Fabian Hueske
> Assignee: Gabor Gevay
>
> This issue is about adding a hash-based combine strategy for ReduceFunctions.
> The interface of the {{reduce()}} method is as follows:
> {code}
> public T reduce(T v1, T v2)
> {code}
> Input type and output type are identical and the function returns only a
> single value. A Reduce function is incrementally applied to compute a final
> aggregated value. This allows to hold the preaggregated value in a hash-table
> and update it with each function call.
> The hash-based strategy requires special implementation of an in-memory hash
> table. The hash table should support in place updates of elements (if the
> updated value has the same size as the new value) but also appending updates
> with invalidation of the old value (if the binary length of the new value
> differs). The hash table needs to be able to evict and emit all elements if
> it runs out-of-memory.
> We should also add {{HASH}} and {{SORT}} compiler hints to
> {{DataSet.reduce()}} and {{Grouping.reduce()}} to allow users to pick the
> execution strategy.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)