diff --git a/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/AbstractOperatorBenchmarkContext.java b/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/AbstractOperatorBenchmarkContext.java index f1e89bacd03379c216cfdc00b999b1e39b3e6687..8bce757c44e27285fc4c1ad6a00bd7737ae1b848 100644 --- a/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/AbstractOperatorBenchmarkContext.java +++ b/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/AbstractOperatorBenchmarkContext.java @@ -23,6 +23,8 @@ import io.prestosql.operator.Operator; import io.prestosql.operator.OperatorFactory; import io.prestosql.operator.TaskContext; import io.prestosql.spi.Page; +import io.prestosql.spi.type.Type; +import io.prestosql.testing.TestingSnapshotUtils; import io.prestosql.testing.TestingTaskContext; import nova.hetu.olk.tool.BlockUtils; import nova.hetu.olk.tool.VecAllocatorHelper; @@ -30,12 +32,14 @@ import nova.hetu.omniruntime.vector.VecAllocator; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.TearDown; +import java.lang.reflect.Field; import java.util.ArrayList; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.concurrent.ExecutorService; import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.ScheduledThreadPoolExecutor; import java.util.concurrent.atomic.AtomicInteger; import static io.airlift.concurrent.Threads.daemonThreadsNamed; @@ -109,7 +113,8 @@ public abstract class AbstractOperatorBenchmarkContext public void setupIteration() { beforeSetupIteration(); - InvocationContext invocationContext = new InvocationContext(); + InvocationContext invocationContext; + invocationContext = new InvocationContext(); invocationContext.driverContext = createTaskContext() .addPipelineContext(0, true, true, false) .addDriverContext(); @@ -127,6 +132,20 @@ public abstract class AbstractOperatorBenchmarkContext protected abstract List buildPages(); + protected List buildPages(List typesArray, int totalPages, int rowsPerPage, boolean dictionaryBlocks) + { + List pages = new ArrayList<>(totalPages); + for (int i = 0; i < totalPages; i++) { + if (dictionaryBlocks) { + pages.add(PageBuilderUtil.createSequencePageWithDictionaryBlocks(typesArray, rowsPerPage)); + } + else { + pages.add(PageBuilderUtil.createSequencePage(typesArray, rowsPerPage)); + } + } + return pages; + } + protected abstract List forkPages(List pages); protected abstract OperatorFactory createOperatorFactory(); @@ -181,6 +200,14 @@ public abstract class AbstractOperatorBenchmarkContext beforeCleanupTrial(); executor.shutdownNow(); scheduledExecutor.shutdownNow(); + try { + Field field = TestingSnapshotUtils.NOOP_SNAPSHOT_UTILS.getClass().getDeclaredField("deleteSnapshotExecutor"); + field.setAccessible(true); + ScheduledThreadPoolExecutor snapshotExecutor = (ScheduledThreadPoolExecutor) field.get(TestingSnapshotUtils.NOOP_SNAPSHOT_UTILS); + snapshotExecutor.shutdownNow(); + } + catch (Exception e) { + } afterCleanupTrial(); } @@ -202,7 +229,7 @@ public abstract class AbstractOperatorBenchmarkContext invocationContext.operator.close(); } catch (Exception e) { - e.printStackTrace(); + System.out.println(e); } } diff --git a/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkAggregationOlkOperator.java b/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkAggregationOlkOperator.java new file mode 100644 index 0000000000000000000000000000000000000000..e9b8f59b7cab7a5c2590ff455caab55b5e2bdd18 --- /dev/null +++ b/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkAggregationOlkOperator.java @@ -0,0 +1,181 @@ +/* + * Copyright (C) 2020-2022. Huawei Technologies Co., Ltd. All rights reserved. + * Licensed 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 nova.hetu.olk.operator.benchmark; + +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import io.prestosql.metadata.Metadata; +import io.prestosql.metadata.MetadataManager; +import io.prestosql.operator.AggregationOperator; +import io.prestosql.operator.OperatorFactory; +import io.prestosql.operator.aggregation.AccumulatorFactory; +import io.prestosql.operator.aggregation.InternalAggregationFunction; +import io.prestosql.spi.Page; +import io.prestosql.spi.connector.QualifiedObjectName; +import io.prestosql.spi.function.Signature; +import io.prestosql.spi.plan.AggregationNode; +import io.prestosql.spi.plan.PlanNodeId; +import io.prestosql.spi.type.Type; +import nova.hetu.olk.operator.benchmark.AbstractOperatorBenchmarkContext.AbstractOlkOperatorBenchmarkContext; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.BenchmarkMode; +import org.openjdk.jmh.annotations.Fork; +import org.openjdk.jmh.annotations.Measurement; +import org.openjdk.jmh.annotations.Mode; +import org.openjdk.jmh.annotations.OutputTimeUnit; +import org.openjdk.jmh.annotations.Param; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.annotations.Threads; +import org.openjdk.jmh.annotations.Warmup; +import org.openjdk.jmh.results.format.ResultFormatType; +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.List; +import java.util.Map; +import java.util.Optional; +import java.util.concurrent.TimeUnit; + +import static io.prestosql.spi.function.FunctionKind.AGGREGATE; +import static io.prestosql.spi.type.BigintType.BIGINT; +import static io.prestosql.spi.type.DoubleType.DOUBLE; + +@State(Scope.Thread) +@Fork(1) +@Threads(1) +@BenchmarkMode(Mode.AverageTime) +@OutputTimeUnit(TimeUnit.MILLISECONDS) +@Warmup(iterations = 3, time = 1) +@Measurement(iterations = 5, time = 1) +public class BenchmarkAggregationOlkOperator +{ + public static final int TOTAL_PAGES = 100; + public static final int ROWS_PER_PAGE = 10000; + + private static final Metadata metadata = MetadataManager.createTestMetadataManager(); + + private static final InternalAggregationFunction LONG_AVERAGE = metadata.getFunctionAndTypeManager().getAggregateFunctionImplementation( + new Signature(QualifiedObjectName.valueOfDefaultFunction("avg"), AGGREGATE, DOUBLE.getTypeSignature(), BIGINT.getTypeSignature())); + private static final InternalAggregationFunction DOUBLE_AVERAGE = metadata.getFunctionAndTypeManager().getAggregateFunctionImplementation( + new Signature(QualifiedObjectName.valueOfDefaultFunction("avg"), AGGREGATE, DOUBLE.getTypeSignature(), DOUBLE.getTypeSignature())); + private static final InternalAggregationFunction DOUBLE_SUM = metadata.getFunctionAndTypeManager().getAggregateFunctionImplementation( + new Signature(QualifiedObjectName.valueOfDefaultFunction("sum"), AGGREGATE, DOUBLE.getTypeSignature(), DOUBLE.getTypeSignature())); + private static final InternalAggregationFunction LONG_SUM = metadata.getFunctionAndTypeManager().getAggregateFunctionImplementation( + new Signature(QualifiedObjectName.valueOfDefaultFunction("sum"), AGGREGATE, BIGINT.getTypeSignature(), BIGINT.getTypeSignature())); + private static final InternalAggregationFunction COUNT = metadata.getFunctionAndTypeManager().getAggregateFunctionImplementation( + new Signature(QualifiedObjectName.valueOfDefaultFunction("count"), AGGREGATE, BIGINT.getTypeSignature())); + private static final InternalAggregationFunction LONG_MAX = metadata.getFunctionAndTypeManager().getAggregateFunctionImplementation( + new Signature(QualifiedObjectName.valueOfDefaultFunction("max"), AGGREGATE, BIGINT.getTypeSignature(), BIGINT.getTypeSignature())); + private static final InternalAggregationFunction LONG_MIN = metadata.getFunctionAndTypeManager().getAggregateFunctionImplementation( + new Signature(QualifiedObjectName.valueOfDefaultFunction("min"), AGGREGATE, BIGINT.getTypeSignature(), BIGINT.getTypeSignature())); + private static final InternalAggregationFunction DOUBLE_MAX = metadata.getFunctionAndTypeManager().getAggregateFunctionImplementation( + new Signature(QualifiedObjectName.valueOfDefaultFunction("max"), AGGREGATE, DOUBLE.getTypeSignature(), DOUBLE.getTypeSignature())); + private static final InternalAggregationFunction DOUBLE_MIN = metadata.getFunctionAndTypeManager().getAggregateFunctionImplementation( + new Signature(QualifiedObjectName.valueOfDefaultFunction("min"), AGGREGATE, DOUBLE.getTypeSignature(), DOUBLE.getTypeSignature())); + + // thus varchar, boolean, decimal cannot aggregation of SUM, AVG + private static final Map> INPUT_TYPES = ImmutableMap + .>builder().put("double", ImmutableList.of(DOUBLE)) + .put("long", ImmutableList.of(BIGINT)) + .build(); + + private static ImmutableList.Builder> maskChannels = new ImmutableList.Builder<>(); + + static { + maskChannels.add(Optional.empty()); + } + + private static List getFactory(String aggType, String group) + { + switch (aggType){ + case "AVG": + if (group.equals("long")) { + return ImmutableList.of(LONG_AVERAGE.bind(ImmutableList.of(0), Optional.empty())); + } + else { + return ImmutableList.of(DOUBLE_AVERAGE.bind(ImmutableList.of(0), Optional.empty())); + } + case "SUM": + if (group.equals("long")) { + return ImmutableList.of(LONG_SUM.bind(ImmutableList.of(0), Optional.empty())); + } + else { + return ImmutableList.of(DOUBLE_SUM.bind(ImmutableList.of(0), Optional.empty())); + } + case "MIN": + if (group.equals("long")) { + return ImmutableList.of(LONG_MIN.bind(ImmutableList.of(0), Optional.empty())); + } + else { + return ImmutableList.of(DOUBLE_MIN.bind(ImmutableList.of(0), Optional.empty())); + } + case "MAX": + if (group.equals("long")) { + return ImmutableList.of(LONG_MAX.bind(ImmutableList.of(0), Optional.empty())); + } + else { + return ImmutableList.of(DOUBLE_MAX.bind(ImmutableList.of(0), Optional.empty())); + } + default: + return ImmutableList.of(COUNT.bind(ImmutableList.of(0), Optional.empty())); + } + } + + @State(Scope.Thread) + public static class BenchmarkContext + extends AbstractOlkOperatorBenchmarkContext + { + @Param({"AVG", "MAX", "MIN", "SUM", "COUNT_COLUMN", "COUNT_ALL"}) + private String aggType = "AVG"; + + @Param({"double", "long"}) + String testGroup = "double"; + + @Override + protected List buildPages() + { + return buildPages(INPUT_TYPES.get(testGroup), TOTAL_PAGES, ROWS_PER_PAGE, false); + } + + @Override + protected OperatorFactory createOperatorFactory() + { + return new AggregationOperator.AggregationOperatorFactory(0, + new PlanNodeId("test"), AggregationNode.Step.SINGLE, + getFactory(aggType, testGroup), false); + } + } + + @Benchmark + public List aggregation(BenchmarkContext context) + { + return context.doDefaultBenchMark(); + } + + public static void main(String[] args) throws RunnerException + { + Options options = new OptionsBuilder().verbosity(VerboseMode.NORMAL) + .include(".*" + BenchmarkAggregationOlkOperator.class.getSimpleName() + ".*") + .resultFormat(ResultFormatType.JSON) + .build(); + + new Runner(options).run(); + } +} diff --git a/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkAggregationOmniOperator.java b/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkAggregationOmniOperator.java new file mode 100644 index 0000000000000000000000000000000000000000..6ac9919a619ac07336972c2e10aa6bd3c1183b18 --- /dev/null +++ b/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkAggregationOmniOperator.java @@ -0,0 +1,154 @@ +/* + * Copyright (C) 2020-2022. Huawei Technologies Co., Ltd. All rights reserved. + * Licensed 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 nova.hetu.olk.operator.benchmark; + +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import io.prestosql.operator.OperatorFactory; +import io.prestosql.spi.Page; +import io.prestosql.spi.plan.AggregationNode; +import io.prestosql.spi.plan.PlanNodeId; +import io.prestosql.spi.type.Type; +import nova.hetu.olk.operator.AggregationOmniOperator; +import nova.hetu.olk.operator.benchmark.AbstractOperatorBenchmarkContext.AbstractOmniOperatorBenchmarkContext; +import nova.hetu.omniruntime.constants.FunctionType; +import nova.hetu.omniruntime.type.DataType; +import nova.hetu.omniruntime.type.DoubleDataType; +import nova.hetu.omniruntime.type.LongDataType; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.BenchmarkMode; +import org.openjdk.jmh.annotations.Fork; +import org.openjdk.jmh.annotations.Measurement; +import org.openjdk.jmh.annotations.Mode; +import org.openjdk.jmh.annotations.OutputTimeUnit; +import org.openjdk.jmh.annotations.Param; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.annotations.Threads; +import org.openjdk.jmh.annotations.Warmup; +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.List; +import java.util.Map; +import java.util.Optional; +import java.util.concurrent.TimeUnit; + +import static io.prestosql.spi.type.BigintType.BIGINT; +import static io.prestosql.spi.type.DoubleType.DOUBLE; +import static nova.hetu.omniruntime.constants.FunctionType.OMNI_AGGREGATION_TYPE_AVG; +import static nova.hetu.omniruntime.constants.FunctionType.OMNI_AGGREGATION_TYPE_COUNT_ALL; +import static nova.hetu.omniruntime.constants.FunctionType.OMNI_AGGREGATION_TYPE_COUNT_COLUMN; +import static nova.hetu.omniruntime.constants.FunctionType.OMNI_AGGREGATION_TYPE_MAX; +import static nova.hetu.omniruntime.constants.FunctionType.OMNI_AGGREGATION_TYPE_MIN; +import static nova.hetu.omniruntime.constants.FunctionType.OMNI_AGGREGATION_TYPE_SUM; + +@State(Scope.Thread) +@Fork(1) +@Threads(1) +@BenchmarkMode(Mode.AverageTime) +@OutputTimeUnit(TimeUnit.MILLISECONDS) +@Warmup(iterations = 3, time = 1) +@Measurement(iterations = 5, time = 1) +public class BenchmarkAggregationOmniOperator +{ + public static final int TOTAL_PAGES = 100; + public static final int ROWS_PER_PAGE = 10000; + + // thus varchar, boolean, decimal cannot aggregation of SUM, AVG + private static final Map> INPUT_TYPES = ImmutableMap + .>builder().put("double", ImmutableList.of(DOUBLE)) + .put("long", ImmutableList.of(BIGINT)) + .build(); + + private static final Map AGG_TYPES = ImmutableMap + .builder().put("SUM", new FunctionType[]{OMNI_AGGREGATION_TYPE_SUM}) + .put("AVG", new FunctionType[]{OMNI_AGGREGATION_TYPE_AVG}) + .put("MAX", new FunctionType[]{OMNI_AGGREGATION_TYPE_MAX}) + .put("MIN", new FunctionType[]{OMNI_AGGREGATION_TYPE_MIN}) + .put("COUNT_COLUMN", new FunctionType[]{OMNI_AGGREGATION_TYPE_COUNT_COLUMN}) + .put("COUNT_ALL", new FunctionType[]{OMNI_AGGREGATION_TYPE_COUNT_ALL}) + .build(); + + private static final DataType[] doubleType = new DataType[]{DoubleDataType.DOUBLE}; + private static final DataType[] longType = new DataType[]{LongDataType.LONG}; + private static ImmutableList.Builder> maskChannels = new ImmutableList.Builder<>(); + + static { + maskChannels.add(Optional.empty()); + } + + private static DataType[] getAggOutput(String aggType, String group) + { + switch (aggType) { + case "COUNT_COLUMN": + case "COUNT_ALL": + return longType; + case "MAX": + case "MIN": + case "SUM": + if (group.equals("long")) { + return longType; + } + else { + return doubleType; + } + default: + return doubleType; + } + } + + @State(Scope.Thread) + public static class BenchmarkContext + extends AbstractOmniOperatorBenchmarkContext + { + @Param({"SUM", "AVG", "MAX", "MIN", "COUNT_COLUMN", "COUNT_ALL"}) + private String aggType = "AVG"; + + @Param({"double", "long"}) + String testGroup = "long"; + + @Override + protected List buildPages() + { + return buildPages(INPUT_TYPES.get(testGroup), TOTAL_PAGES, ROWS_PER_PAGE, false); + } + + @Override + protected OperatorFactory createOperatorFactory() + { + return new AggregationOmniOperator.AggregationOmniOperatorFactory(0, + new PlanNodeId("test"), INPUT_TYPES.get(testGroup), AGG_TYPES.get(aggType), new int[]{0}, + maskChannels.build(), getAggOutput(aggType, testGroup), AggregationNode.Step.SINGLE); + } + } + + @Benchmark + public List aggregation(BenchmarkContext context) + { + return context.doDefaultBenchMark(); + } + + public static void main(String[] args) throws RunnerException + { + Options options = new OptionsBuilder().verbosity(VerboseMode.NORMAL) + .include(".*" + BenchmarkAggregationOmniOperator.class.getSimpleName() + ".*").build(); + new Runner(options).run(); + } +} diff --git a/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkBuildOffHeapOmniOperator.java b/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkBuildOffHeapOmniOperator.java index 175ec3a368549ff5b12a0eb9063df2bf82cf5f46..3144cc82a3d240cc13e64e248d9a85565118bcc2 100644 --- a/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkBuildOffHeapOmniOperator.java +++ b/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkBuildOffHeapOmniOperator.java @@ -47,12 +47,14 @@ import java.util.concurrent.TimeUnit; import static io.prestosql.spi.type.BigintType.BIGINT; import static io.prestosql.spi.type.BooleanType.BOOLEAN; +import static io.prestosql.spi.type.DateType.DATE; +import static io.prestosql.spi.type.DecimalType.createDecimalType; import static io.prestosql.spi.type.DoubleType.DOUBLE; import static io.prestosql.spi.type.IntegerType.INTEGER; import static io.prestosql.spi.type.VarcharType.createVarcharType; @State(Scope.Thread) -@Fork(0) +@Fork(1) @Threads(1) @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.MILLISECONDS) @@ -66,6 +68,7 @@ public class BenchmarkBuildOffHeapOmniOperator private static final Map> INPUT_TYPES = ImmutableMap .>builder().put("boolean", ImmutableList.of(BOOLEAN)) .put("long", ImmutableList.of(BIGINT)).put("int", ImmutableList.of(INTEGER)) + .put("decimal", ImmutableList.of(createDecimalType())).put("date", ImmutableList.of(DATE)) .put("double", ImmutableList.of(DOUBLE)).put("varchar", ImmutableList.of(createVarcharType(50))) .build(); @@ -73,7 +76,7 @@ public class BenchmarkBuildOffHeapOmniOperator public static class BenchmarkContext extends AbstractOmniOperatorBenchmarkContext { - @Param({"int", "long", "double", "varchar"}) + @Param({"int", "long", "boolean", "double", "decimal", "date", "varchar"}) String testGroup = "int"; @Param({"false", "true"}) @@ -82,17 +85,7 @@ public class BenchmarkBuildOffHeapOmniOperator @Override protected List buildPages() { - List typesArray = INPUT_TYPES.get(testGroup); - List pages = new ArrayList<>(); - for (int i = 0; i < TOTAL_PAGES; i++) { - if (dictionaryBlocks) { - pages.add(PageBuilderUtil.createSequencePageWithDictionaryBlocks(typesArray, ROWS_PER_PAGE)); - } - else { - pages.add(PageBuilderUtil.createSequencePage(typesArray, ROWS_PER_PAGE)); - } - } - return pages; + return buildPages(INPUT_TYPES.get(testGroup), TOTAL_PAGES, ROWS_PER_PAGE, dictionaryBlocks); } @Override diff --git a/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkBuildOnHeapOmniOperator.java b/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkBuildOnHeapOmniOperator.java index 42fba13acfe01ea3244441e39a9a6e983d867b24..ea284eb8069e9ff38fe8291c6a61015232b63a68 100644 --- a/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkBuildOnHeapOmniOperator.java +++ b/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkBuildOnHeapOmniOperator.java @@ -39,19 +39,20 @@ import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import org.openjdk.jmh.runner.options.VerboseMode; -import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.concurrent.TimeUnit; import static io.prestosql.spi.type.BigintType.BIGINT; import static io.prestosql.spi.type.BooleanType.BOOLEAN; +import static io.prestosql.spi.type.DateType.DATE; +import static io.prestosql.spi.type.DecimalType.createDecimalType; import static io.prestosql.spi.type.DoubleType.DOUBLE; import static io.prestosql.spi.type.IntegerType.INTEGER; import static io.prestosql.spi.type.VarcharType.createVarcharType; @State(Scope.Thread) -@Fork(0) +@Fork(1) @Threads(1) @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.MILLISECONDS) @@ -65,6 +66,7 @@ public class BenchmarkBuildOnHeapOmniOperator private static final Map> INPUT_TYPES = ImmutableMap .>builder().put("boolean", ImmutableList.of(BOOLEAN)) .put("long", ImmutableList.of(BIGINT)).put("int", ImmutableList.of(INTEGER)) + .put("decimal", ImmutableList.of(createDecimalType())).put("date", ImmutableList.of(DATE)) .put("double", ImmutableList.of(DOUBLE)).put("varchar", ImmutableList.of(createVarcharType(50))) .build(); @@ -72,7 +74,7 @@ public class BenchmarkBuildOnHeapOmniOperator public static class BenchmarkContext extends AbstractOmniOperatorBenchmarkContext { - @Param({"int", "long", "double", "varchar"}) + @Param({"int", "long", "boolean", "double", "decimal", "date", "varchar"}) String testGroup = "int"; @Param({"false", "true"}) @@ -81,16 +83,7 @@ public class BenchmarkBuildOnHeapOmniOperator @Override protected List buildPages() { - List pages = new ArrayList<>(); - for (int i = 0; i < TOTAL_PAGES; i++) { - if (dictionaryBlocks) { - pages.add(PageBuilderUtil.createSequencePageWithDictionaryBlocks(INPUT_TYPES.get(testGroup), ROWS_PER_PAGE)); - } - else { - pages.add(PageBuilderUtil.createSequencePage(INPUT_TYPES.get(testGroup), ROWS_PER_PAGE)); - } - } - return pages; + return buildPages(INPUT_TYPES.get(testGroup), TOTAL_PAGES, ROWS_PER_PAGE, dictionaryBlocks); } @Override diff --git a/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkDistinctLimitOlkOperator.java b/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkDistinctLimitOlkOperator.java index e80013bd14e8cb942460a669ded5e992a7b2017a..97a381807091b61a55991f71b8555b9b9a811a34 100644 --- a/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkDistinctLimitOlkOperator.java +++ b/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkDistinctLimitOlkOperator.java @@ -41,7 +41,6 @@ import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import org.openjdk.jmh.runner.options.VerboseMode; -import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Optional; @@ -55,7 +54,7 @@ import static io.prestosql.spi.type.IntegerType.INTEGER; import static io.prestosql.spi.type.VarcharType.createVarcharType; @State(Scope.Thread) -@Fork(0) +@Fork(1) @Threads(1) @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.MILLISECONDS) @@ -86,7 +85,7 @@ public class BenchmarkDistinctLimitOlkOperator public static class BenchmarkContext extends AbstractOlkOperatorBenchmarkContext { - @Param({"1", "100", "10000", "100000"}) + @Param({"100", "10000", "100000"}) private String limit = "100"; @Param({"group1", "group2", "group3", "group4", "group5", "group6", "group7", "group8"}) @@ -101,18 +100,7 @@ public class BenchmarkDistinctLimitOlkOperator @Override protected List buildPages() { - List typesArray = INPUT_TYPES.get(testGroup); - List pages = new ArrayList<>(TOTAL_PAGES); - for (int i = 0; i < TOTAL_PAGES; i++) { - if (dictionaryBlocks) { - pages.add(PageBuilderUtil.createSequencePageWithDictionaryBlocks(typesArray, - Integer.parseInt(rowsPerPageStr))); - } - else { - pages.add(PageBuilderUtil.createSequencePage(typesArray, Integer.parseInt(rowsPerPageStr))); - } - } - return pages; + return buildPages(INPUT_TYPES.get(testGroup), TOTAL_PAGES, Integer.parseInt(rowsPerPageStr), dictionaryBlocks); } @Override diff --git a/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkDistinctLimitOmniOperator.java b/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkDistinctLimitOmniOperator.java index 24b92baf704fd1d9945770fcbf9933e312dd6d30..adcd2ead4801d49d5cc8f5dfa577856b5c5d75d7 100644 --- a/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkDistinctLimitOmniOperator.java +++ b/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkDistinctLimitOmniOperator.java @@ -40,7 +40,6 @@ import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import org.openjdk.jmh.runner.options.VerboseMode; -import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Optional; @@ -53,7 +52,7 @@ import static io.prestosql.spi.type.IntegerType.INTEGER; import static io.prestosql.spi.type.VarcharType.createVarcharType; @State(Scope.Thread) -@Fork(0) +@Fork(1) @Threads(1) @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.MILLISECONDS) @@ -86,7 +85,7 @@ public class BenchmarkDistinctLimitOmniOperator public static class BenchmarkContext extends AbstractOmniOperatorBenchmarkContext { - @Param({"1", "100", "10000", "100000"}) + @Param({"100", "10000", "100000"}) private String limit = "100"; @Param({"group1", "group2", "group3", "group4", "group5", "group6", "group7", "group8"}) @@ -101,18 +100,7 @@ public class BenchmarkDistinctLimitOmniOperator @Override protected List buildPages() { - List typesArray = INPUT_TYPES.get(testGroup); - List pages = new ArrayList<>(TOTAL_PAGES); - for (int i = 0; i < TOTAL_PAGES; i++) { - if (dictionaryBlocks) { - pages.add(PageBuilderUtil.createSequencePageWithDictionaryBlocks(typesArray, - Integer.parseInt(rowsPerPageStr))); - } - else { - pages.add(PageBuilderUtil.createSequencePage(typesArray, Integer.parseInt(rowsPerPageStr))); - } - } - return pages; + return buildPages(INPUT_TYPES.get(testGroup), TOTAL_PAGES, Integer.parseInt(rowsPerPageStr), dictionaryBlocks); } @Override diff --git a/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkEnforceSingleRowOlkOperator.java b/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkEnforceSingleRowOlkOperator.java new file mode 100644 index 0000000000000000000000000000000000000000..513c412e27b455b503228b33446173522d1c8360 --- /dev/null +++ b/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkEnforceSingleRowOlkOperator.java @@ -0,0 +1,155 @@ +/* + * Copyright (C) 2020-2022. Huawei Technologies Co., Ltd. All rights reserved. + * Licensed 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 nova.hetu.olk.operator.benchmark; + +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import io.prestosql.operator.DriverContext; +import io.prestosql.operator.EnforceSingleRowOperator; +import io.prestosql.operator.OperatorFactory; +import io.prestosql.operator.TaskContext; +import io.prestosql.spi.Page; +import io.prestosql.spi.PrestoException; +import io.prestosql.spi.plan.PlanNodeId; +import io.prestosql.spi.type.Type; +import io.prestosql.testing.TestingSnapshotUtils; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.BenchmarkMode; +import org.openjdk.jmh.annotations.Fork; +import org.openjdk.jmh.annotations.Measurement; +import org.openjdk.jmh.annotations.Mode; +import org.openjdk.jmh.annotations.OutputTimeUnit; +import org.openjdk.jmh.annotations.Param; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.Setup; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.annotations.TearDown; +import org.openjdk.jmh.annotations.Warmup; +import org.openjdk.jmh.infra.Blackhole; +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.lang.reflect.Field; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.ScheduledThreadPoolExecutor; +import java.util.concurrent.TimeUnit; + +import static io.airlift.concurrent.Threads.daemonThreadsNamed; +import static io.prestosql.RowPagesBuilder.rowPagesBuilder; +import static io.prestosql.SessionTestUtils.TEST_SESSION; +import static io.prestosql.spi.type.BigintType.BIGINT; +import static io.prestosql.spi.type.BooleanType.BOOLEAN; +import static io.prestosql.spi.type.DateType.DATE; +import static io.prestosql.spi.type.DecimalType.createDecimalType; +import static io.prestosql.spi.type.DoubleType.DOUBLE; +import static io.prestosql.spi.type.VarcharType.createVarcharType; +import static io.prestosql.testing.TestingTaskContext.createTaskContext; +import static java.util.concurrent.Executors.newCachedThreadPool; +import static java.util.concurrent.Executors.newScheduledThreadPool; + +public class BenchmarkEnforceSingleRowOlkOperator +{ + private BenchmarkEnforceSingleRowOlkOperator() + { + } + + private static final Map> INPUT_TYPES = ImmutableMap + .>builder().put("boolean", ImmutableList.of(BOOLEAN)) + .put("long", ImmutableList.of(BIGINT)) + .put("decimal", ImmutableList.of(createDecimalType())).put("date", ImmutableList.of(DATE)) + .put("double", ImmutableList.of(DOUBLE)).put("varchar", ImmutableList.of(createVarcharType(50))) + .build(); + + @State(Scope.Thread) + @OutputTimeUnit(TimeUnit.MILLISECONDS) + @BenchmarkMode(Mode.AverageTime) + @Fork(1) + @Warmup(iterations = 3, time = 1) + @Measurement(iterations = 5, time = 1) + public static class BenchmarkContext + { + private ExecutorService executor; + private ScheduledExecutorService scheduledExecutor; + private TaskContext taskContext; + private OperatorFactory factory; + + @Param({"long", "boolean", "double", "decimal", "date", "varchar"}) + String testGroup = "long"; + + @Setup + public void setUp() + { + executor = newCachedThreadPool(daemonThreadsNamed("test-executor-%s")); + scheduledExecutor = newScheduledThreadPool(2, daemonThreadsNamed("test-scheduledExecutor-%s")); + taskContext = createTaskContext(executor, scheduledExecutor, TEST_SESSION); + factory = new EnforceSingleRowOperator.EnforceSingleRowOperatorFactory(0, + new PlanNodeId("plan-node-0")); + } + + @TearDown + public void tearDown() + { + executor.shutdownNow(); + scheduledExecutor.shutdownNow(); + try { + Class cl = TestingSnapshotUtils.NOOP_SNAPSHOT_UTILS.getClass(); + Field field = cl.getDeclaredField("deleteSnapshotExecutor"); + field.setAccessible(true); + ScheduledThreadPoolExecutor snapshotExecutor = (ScheduledThreadPoolExecutor) field.get(TestingSnapshotUtils.NOOP_SNAPSHOT_UTILS); + snapshotExecutor.shutdownNow(); + } + catch (NoSuchFieldException | IllegalAccessException e) { + } + } + + @Benchmark + public void testEnforceSingleRowOlkOperator(Blackhole blackhole) + { + DriverContext driverContext = taskContext.addPipelineContext(0, true, true, false).addDriverContext(); + EnforceSingleRowOperator operator = (EnforceSingleRowOperator) factory.createOperator(driverContext); + List input = buildPages(testGroup); + operator.addInput(input.get(0)); + + try { + operator.addInput(input.get(1)); + } + catch (PrestoException e) { + } + blackhole.consume(input); + operator.finish(); + operator.close(); + } + } + + public static List buildPages(String testGroup) + { + return rowPagesBuilder(INPUT_TYPES.get(testGroup)).addSequencePage(1, 1).addSequencePage(2, 1).build(); + } + + public static void main(String[] args) throws RunnerException + { + Options options = new OptionsBuilder().verbosity(VerboseMode.NORMAL) + .include("nova.hetu.olk.operator.benchmark." + BenchmarkEnforceSingleRowOlkOperator.class.getSimpleName() + ".*").build(); + + new Runner(options).run(); + } +} diff --git a/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkEnforceSingleRowOmniOperator.java b/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkEnforceSingleRowOmniOperator.java new file mode 100644 index 0000000000000000000000000000000000000000..71df91eb71914d7fee80bc863273932ec3c02e8d --- /dev/null +++ b/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkEnforceSingleRowOmniOperator.java @@ -0,0 +1,163 @@ +/* + * Copyright (C) 2020-2022. Huawei Technologies Co., Ltd. All rights reserved. + * Licensed 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 nova.hetu.olk.operator.benchmark; + +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import io.prestosql.operator.DriverContext; +import io.prestosql.operator.EnforceSingleRowOperator; +import io.prestosql.operator.OperatorFactory; +import io.prestosql.operator.TaskContext; +import io.prestosql.spi.Page; +import io.prestosql.spi.PrestoException; +import io.prestosql.spi.plan.PlanNodeId; +import io.prestosql.spi.type.Type; +import io.prestosql.testing.TestingSnapshotUtils; +import nova.hetu.olk.operator.EnforceSingleRowOmniOperator; +import nova.hetu.olk.tool.BlockUtils; +import nova.hetu.omniruntime.vector.VecAllocator; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.BenchmarkMode; +import org.openjdk.jmh.annotations.Fork; +import org.openjdk.jmh.annotations.Measurement; +import org.openjdk.jmh.annotations.Mode; +import org.openjdk.jmh.annotations.OutputTimeUnit; +import org.openjdk.jmh.annotations.Param; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.Setup; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.annotations.TearDown; +import org.openjdk.jmh.annotations.Warmup; +import org.openjdk.jmh.infra.Blackhole; +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.lang.reflect.Field; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.ScheduledThreadPoolExecutor; +import java.util.concurrent.TimeUnit; + +import static io.airlift.concurrent.Threads.daemonThreadsNamed; +import static io.prestosql.RowPagesBuilder.rowPagesBuilder; +import static io.prestosql.SessionTestUtils.TEST_SESSION; +import static io.prestosql.spi.type.BigintType.BIGINT; +import static io.prestosql.spi.type.BooleanType.BOOLEAN; +import static io.prestosql.spi.type.DateType.DATE; +import static io.prestosql.spi.type.DecimalType.createDecimalType; +import static io.prestosql.spi.type.DoubleType.DOUBLE; +import static io.prestosql.spi.type.IntegerType.INTEGER; +import static io.prestosql.spi.type.VarcharType.createVarcharType; +import static io.prestosql.testing.TestingTaskContext.createTaskContext; +import static java.util.concurrent.Executors.newCachedThreadPool; +import static java.util.concurrent.Executors.newScheduledThreadPool; +import static nova.hetu.olk.tool.OperatorUtils.transferToOffHeapPages; + +public class BenchmarkEnforceSingleRowOmniOperator +{ + private BenchmarkEnforceSingleRowOmniOperator() + { + } + + private static final Map> INPUT_TYPES = ImmutableMap + .>builder().put("boolean", ImmutableList.of(BOOLEAN)) + .put("long", ImmutableList.of(BIGINT)).put("int", ImmutableList.of(INTEGER)) + .put("decimal", ImmutableList.of(createDecimalType())).put("date", ImmutableList.of(DATE)) + .put("double", ImmutableList.of(DOUBLE)).put("varchar", ImmutableList.of(createVarcharType(50))) + .build(); + + @State(Scope.Thread) + @OutputTimeUnit(TimeUnit.MILLISECONDS) + @BenchmarkMode(Mode.AverageTime) + @Fork(1) + @Warmup(iterations = 3, time = 1) + @Measurement(iterations = 5, time = 1) + public static class BenchmarkContext + { + private ExecutorService executor; + private ScheduledExecutorService scheduledExecutor; + private TaskContext taskContext; + + @Param({"long", "boolean", "double", "decimal", "date", "varchar"}) + String testGroup = "long"; + + @Setup + public void setUp() + { + executor = newCachedThreadPool(daemonThreadsNamed("test-executor-%s")); + scheduledExecutor = newScheduledThreadPool(2, daemonThreadsNamed("test-scheduledExecutor-%s")); + taskContext = createTaskContext(executor, scheduledExecutor, TEST_SESSION); + } + + @TearDown + public void tearDown() + { + executor.shutdownNow(); + scheduledExecutor.shutdownNow(); + try { + Class cl = TestingSnapshotUtils.NOOP_SNAPSHOT_UTILS.getClass(); + Field field = cl.getDeclaredField("deleteSnapshotExecutor"); + field.setAccessible(true); + ScheduledThreadPoolExecutor snapshotExecutor = (ScheduledThreadPoolExecutor) field.get(TestingSnapshotUtils.NOOP_SNAPSHOT_UTILS); + snapshotExecutor.shutdownNow(); + } + catch (NoSuchFieldException | IllegalAccessException e) { + } + } + + @Benchmark + public void testEnforceSingleRowOmniOperator(Blackhole blackhole) + { + DriverContext driverContext = taskContext.addPipelineContext(0, true, true, false).addDriverContext(); + OperatorFactory factory = new EnforceSingleRowOmniOperator.EnforceSingleRowOmniOperatorFactory(0, + new PlanNodeId("plan-node-0"), INPUT_TYPES.get(testGroup)); + factory = factory.duplicate(); + EnforceSingleRowOperator operator = (EnforceSingleRowOperator) factory.createOperator(driverContext); + factory.noMoreOperators(); + List input = buildPages(testGroup); + operator.addInput(input.get(0)); + + try { + operator.addInput(input.get(1)); + } + catch (PrestoException e) { + } + blackhole.consume(input); + BlockUtils.freePage(input.get(0)); + BlockUtils.freePage(input.get(1)); + operator.finish(); + } + } + + public static List buildPages(String testGroup) + { + List pages = rowPagesBuilder(INPUT_TYPES.get(testGroup)).addSequencePage(1, 1).addSequencePage(2, 1).build(); + return transferToOffHeapPages(VecAllocator.GLOBAL_VECTOR_ALLOCATOR, pages); + } + + public static void main(String[] args) throws RunnerException + { + Options options = new OptionsBuilder().verbosity(VerboseMode.NORMAL) + .include("nova.hetu.olk.operator.benchmark." + BenchmarkEnforceSingleRowOmniOperator.class.getSimpleName() + ".*").build(); + + new Runner(options).run(); + } +} diff --git a/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkFilterAndProjectOlkOperator.java b/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkFilterAndProjectOlkOperator.java index 7c6f09f0dd9f8ea50d55bf7fdd7468c58cd4da0a..4a4681499f24ce1b8b3bfd1aa3cdba41245038e8 100644 --- a/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkFilterAndProjectOlkOperator.java +++ b/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkFilterAndProjectOlkOperator.java @@ -56,7 +56,6 @@ import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import org.openjdk.jmh.runner.options.VerboseMode; -import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -77,7 +76,7 @@ import static org.openjdk.jmh.annotations.Scope.Thread; @SuppressWarnings({"PackageVisibleField", "FieldCanBeLocal"}) @State(Scope.Thread) @OutputTimeUnit(TimeUnit.MILLISECONDS) -@Fork(0) +@Fork(1) @Threads(1) @Warmup(iterations = 3, time = 1) @Measurement(iterations = 5, time = 1) @@ -103,7 +102,8 @@ public class BenchmarkFilterAndProjectOlkOperator .put("q3", ImmutableList.of(VARCHAR, VARCHAR, INTEGER)) .put("q4", ImmutableList.of(VARCHAR, INTEGER, INTEGER)) .put("q5", ImmutableList.of(CHAR, INTEGER, INTEGER)) - .put("q6", ImmutableList.of(VARCHAR, BIGINT, INTEGER)).put("q7", ImmutableList.of(VARCHAR, INTEGER)) + .put("q6", ImmutableList.of(VARCHAR, BIGINT, INTEGER)) + .put("q7", ImmutableList.of(VARCHAR, INTEGER)) .put("q8", ImmutableList.of(VARCHAR, VARCHAR, BIGINT, INTEGER)) .put("q9", ImmutableList.of(BIGINT, INTEGER, INTEGER, VARCHAR)) .put("q10", ImmutableList.of(BIGINT, INTEGER, INTEGER, VARCHAR)).build(); @@ -143,17 +143,8 @@ public class BenchmarkFilterAndProjectOlkOperator @Override protected List buildPages() { - List types = INPUT_TYPES.get(this.query); - List pages = new ArrayList<>(); - for (int i = 0; i < TOTAL_POSITIONS / positionsPerPage; i++) { - if (dictionaryBlocks) { - pages.add(PageBuilderUtil.createSequencePageWithDictionaryBlocks(types, positionsPerPage)); - } - else { - pages.add(PageBuilderUtil.createSequencePage(types, positionsPerPage)); - } - } - return pages; + return buildPages(INPUT_TYPES.get(this.query), TOTAL_POSITIONS / positionsPerPage, + positionsPerPage, dictionaryBlocks); } @Override @@ -244,7 +235,7 @@ public class BenchmarkFilterAndProjectOlkOperator break; } case "q7": { - builder.add(rowExpression("substr(varchar0, 1, 1)")); + builder.add(rowExpression("substr(varchar0, 0, 1)")); builder.add(rowExpression("integer1")); break; } @@ -259,14 +250,14 @@ public class BenchmarkFilterAndProjectOlkOperator builder.add(rowExpression("bigint0")); builder.add(rowExpression("cast(integer1 as BIGINT)")); builder.add(rowExpression("cast(integer2 as BIGINT)")); - builder.add(rowExpression("substr(varchar3, 1, 1)")); + builder.add(rowExpression("substr(varchar3, 0, 1)")); break; } case "q10": { builder.add(rowExpression("bigint0")); builder.add(rowExpression("cast(integer1 as BIGINT)")); builder.add(rowExpression("integer2")); - builder.add(rowExpression("substr(varchar3, 1, 1)")); + builder.add(rowExpression("substr(varchar3, 0, 1)")); break; } default: diff --git a/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkFilterAndProjectOmniOperator.java b/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkFilterAndProjectOmniOperator.java index b1d917115997cc1ada6badb769dc9fc351f612d3..a425ff23c0c7b2398a0b2377451cb8b57020b088 100644 --- a/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkFilterAndProjectOmniOperator.java +++ b/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkFilterAndProjectOmniOperator.java @@ -57,7 +57,6 @@ import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import org.openjdk.jmh.runner.options.VerboseMode; -import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -79,7 +78,7 @@ import static org.openjdk.jmh.annotations.Scope.Thread; @SuppressWarnings({"PackageVisibleField", "FieldCanBeLocal"}) @State(Scope.Thread) @OutputTimeUnit(TimeUnit.MILLISECONDS) -@Fork(0) +@Fork(1) @Threads(1) @Warmup(iterations = 3, time = 1) @Measurement(iterations = 5, time = 1) @@ -105,7 +104,8 @@ public class BenchmarkFilterAndProjectOmniOperator .put("q3", ImmutableList.of(VARCHAR, VARCHAR, INTEGER)) .put("q4", ImmutableList.of(VARCHAR, INTEGER, INTEGER)) .put("q5", ImmutableList.of(CHAR, INTEGER, INTEGER)) - .put("q6", ImmutableList.of(VARCHAR, BIGINT, INTEGER)).put("q7", ImmutableList.of(VARCHAR, INTEGER)) + .put("q6", ImmutableList.of(VARCHAR, BIGINT, INTEGER)) + .put("q7", ImmutableList.of(VARCHAR, INTEGER)) .put("q8", ImmutableList.of(VARCHAR, VARCHAR, BIGINT, INTEGER)) .put("q9", ImmutableList.of(BIGINT, INTEGER, INTEGER, VARCHAR)) .put("q10", ImmutableList.of(BIGINT, INTEGER, INTEGER, VARCHAR)).build(); @@ -145,17 +145,8 @@ public class BenchmarkFilterAndProjectOmniOperator @Override protected List buildPages() { - List types = INPUT_TYPES.get(this.query); - List pages = new ArrayList<>(); - for (int i = 0; i < TOTAL_POSITIONS / positionsPerPage; i++) { - if (dictionaryBlocks) { - pages.add(PageBuilderUtil.createSequencePageWithDictionaryBlocks(types, positionsPerPage)); - } - else { - pages.add(PageBuilderUtil.createSequencePage(types, positionsPerPage)); - } - } - return pages; + return buildPages(INPUT_TYPES.get(this.query), TOTAL_POSITIONS / positionsPerPage, + positionsPerPage, dictionaryBlocks); } @Override @@ -235,6 +226,7 @@ public class BenchmarkFilterAndProjectOmniOperator break; } case "q5": { + // 'concat' function lead to MEMORY_LEAK builder.add(rowExpression("concat(concat('foo', char0), 'lish')")); builder.add(rowExpression("integer1")); builder.add(rowExpression("integer2")); @@ -247,7 +239,7 @@ public class BenchmarkFilterAndProjectOmniOperator break; } case "q7": { - builder.add(rowExpression("substr(varchar0, 1, 1)")); + builder.add(rowExpression("substr(varchar0, 0, 1)")); builder.add(rowExpression("integer1")); break; } @@ -262,14 +254,14 @@ public class BenchmarkFilterAndProjectOmniOperator builder.add(rowExpression("bigint0")); builder.add(rowExpression("cast(integer1 as BIGINT)")); builder.add(rowExpression("cast(integer2 as BIGINT)")); - builder.add(rowExpression("substr(varchar3, 1, 1)")); + builder.add(rowExpression("substr(varchar3, 0, 1)")); break; } case "q10": { builder.add(rowExpression("bigint0")); builder.add(rowExpression("cast(integer1 as BIGINT)")); builder.add(rowExpression("integer2")); - builder.add(rowExpression("substr(varchar3, 1, 1)")); + builder.add(rowExpression("substr(varchar3, 0, 1)")); break; } default: diff --git a/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkHashAggregationOlkOperator.java b/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkHashAggregationOlkOperator.java index 8b82154cb74a1bd32feb0f66e4d8b3268c063cba..8ea1846d38ea207085eb4f29e964c8b4a35cb5a3 100644 --- a/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkHashAggregationOlkOperator.java +++ b/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkHashAggregationOlkOperator.java @@ -71,7 +71,7 @@ import static java.lang.String.format; import static org.openjdk.jmh.annotations.Scope.Thread; @State(Scope.Thread) -@Fork(0) +@Fork(1) @Threads(1) @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.MILLISECONDS) @@ -114,21 +114,6 @@ public class BenchmarkHashAggregationOlkOperator .put("sql6", ImmutableList.of(INTEGER, INTEGER)) .put("sql7", ImmutableList.of(FIXED_WIDTH_VARCHAR, FIXED_WIDTH_VARCHAR, FIXED_WIDTH_VARCHAR)) .put("sql9", ImmutableList.of(BIGINT, BIGINT, BIGINT, FIXED_WIDTH_VARCHAR)).build(); - private static final Map> aggChannels = new ImmutableMap.Builder>() - .put("sql2", ImmutableList.of(6)).put("sql4", ImmutableList.of(4)).put("sql6", ImmutableList.of(2)) - .put("sql7", ImmutableList.of(3, 4, 5, 6, 7)).put("sql9", ImmutableList.of(4, 5)).build(); - private static final Map> aggInputTypes = new ImmutableMap.Builder>() - .put("sql2", ImmutableList.of(BIGINT)).put("sql4", ImmutableList.of(BIGINT)) - .put("sql6", ImmutableList.of(BIGINT)).put("sql7", ImmutableList.of(BIGINT, BIGINT, BIGINT, BIGINT, BIGINT)) - .put("sql9", ImmutableList.of(BIGINT, BIGINT)).build(); - private static final Map> aggOutputTypes = new ImmutableMap.Builder>() - .put("sql2", ImmutableList.of(BIGINT)).put("sql4", ImmutableList.of(BIGINT)) - .put("sql6", ImmutableList.of(BIGINT)).put("sql7", ImmutableList.of(BIGINT, BIGINT, BIGINT, BIGINT, BIGINT)) - .put("sql9", ImmutableList.of(BIGINT, BIGINT)).build(); - private static final Map> aggFuncTypes = new ImmutableMap.Builder>() - .put("sql2", ImmutableList.of("sum")).put("sql4", ImmutableList.of("sum")) - .put("sql6", ImmutableList.of("sum")).put("sql7", ImmutableList.of("sum", "sum", "sum", "sum", "sum")) - .put("sql9", ImmutableList.of("sum", "sum")).build(); public static final int TOTAL_PAGES = 140; public static final int ROWS_PER_PAGE = 10_000; diff --git a/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkHashAggregationOmniOperator.java b/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkHashAggregationOmniOperator.java index 4f24bcd873c344e85f73fde7c5f53f2e1d6f923a..2844757269b49eef38ac7ee62cc9d3f04d51c14f 100644 --- a/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkHashAggregationOmniOperator.java +++ b/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkHashAggregationOmniOperator.java @@ -75,7 +75,7 @@ import static nova.hetu.omniruntime.constants.FunctionType.OMNI_AGGREGATION_TYPE import static org.openjdk.jmh.annotations.Scope.Thread; @State(Scope.Thread) -@Fork(0) +@Fork(1) @Threads(1) @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.MILLISECONDS) @@ -103,10 +103,6 @@ public class BenchmarkHashAggregationOmniOperator ImmutableList.of(FIXED_WIDTH_VARCHAR, FIXED_WIDTH_VARCHAR, FIXED_WIDTH_VARCHAR, BIGINT, BIGINT, BIGINT, BIGINT, BIGINT)) .put("sql9", ImmutableList.of(BIGINT, BIGINT, BIGINT, FIXED_WIDTH_VARCHAR, BIGINT, BIGINT)).build(); - private static final Map> channels = new ImmutableMap.Builder>() - .put("sql2", ImmutableList.of(0, 1, 2, 3, 4, 5, 6)).put("sql4", ImmutableList.of(0, 1, 2, 3, 4)) - .put("sql6", ImmutableList.of(0, 1, 2)).put("sql7", ImmutableList.of(0, 1, 2, 3, 4, 5, 6, 7)) - .put("sql9", ImmutableList.of(0, 1, 2, 3, 4, 5)).build(); private static final Map> hashChannels = new ImmutableMap.Builder>() .put("sql2", ImmutableList.of(0, 1, 2, 3, 4, 5)).put("sql4", ImmutableList.of(0, 1, 2, 3)) .put("sql6", ImmutableList.of(0, 1)).put("sql7", ImmutableList.of(0, 1, 2)) @@ -131,9 +127,9 @@ public class BenchmarkHashAggregationOmniOperator .put("sql6", ImmutableList.of(BIGINT)).put("sql7", ImmutableList.of(BIGINT, BIGINT, BIGINT, BIGINT, BIGINT)) .put("sql9", ImmutableList.of(BIGINT, BIGINT)).build(); private static final Map> aggFuncTypes = new ImmutableMap.Builder>() - .put("sql2", ImmutableList.of("sum")).put("sql4", ImmutableList.of("sum")) - .put("sql6", ImmutableList.of("sum")).put("sql7", ImmutableList.of("sum", "sum", "sum", "sum", "sum")) - .put("sql9", ImmutableList.of("sum", "sum")).build(); + .put("sql2", ImmutableList.of("sum")).put("sql4", ImmutableList.of("max")) + .put("sql6", ImmutableList.of("count")).put("sql7", ImmutableList.of("sum", "sum", "sum", "sum", "sum")) + .put("sql9", ImmutableList.of("avg", "min")).build(); public static final int TOTAL_PAGES = 140; public static final int ROWS_PER_PAGE = 10_000; diff --git a/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkHashJoinOlkOperators.java b/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkHashJoinOlkOperators.java index 705621479fbb80b1737ede9a15a86a596629e52b..fb882a65587c972b9bd175698fe49dcb258f72b8 100644 --- a/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkHashJoinOlkOperators.java +++ b/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkHashJoinOlkOperators.java @@ -80,7 +80,7 @@ import static org.openjdk.jmh.annotations.Scope.Thread; @State(Thread) @OutputTimeUnit(MILLISECONDS) @BenchmarkMode(AverageTime) -@Fork(0) +@Fork(2) @Threads(1) @Warmup(iterations = 3, time = 1) @Measurement(iterations = 5, time = 1) diff --git a/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkHashJoinOmniOperators.java b/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkHashJoinOmniOperators.java index 3b567945c5dd373b0752ad3f1ed58203fde10036..b13d05086eaced5151a1f1ad2f89b16a4c499930 100644 --- a/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkHashJoinOmniOperators.java +++ b/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkHashJoinOmniOperators.java @@ -80,7 +80,7 @@ import static org.openjdk.jmh.annotations.Scope.Thread; @State(Thread) @OutputTimeUnit(MILLISECONDS) @BenchmarkMode(AverageTime) -@Fork(0) +@Fork(2) @Threads(1) @Warmup(iterations = 3, time = 1) @Measurement(iterations = 5, time = 1) diff --git a/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkLimitOlkOperator.java b/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkLimitOlkOperator.java index adc17026fcaba0637efe01da8b3f9a33e9c1222a..a05d03265ce465e0847398a433c408c0411f0f15 100644 --- a/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkLimitOlkOperator.java +++ b/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkLimitOlkOperator.java @@ -40,19 +40,19 @@ import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import org.openjdk.jmh.runner.options.VerboseMode; -import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.concurrent.TimeUnit; import static io.prestosql.spi.type.BigintType.BIGINT; +import static io.prestosql.spi.type.DateType.DATE; import static io.prestosql.spi.type.DecimalType.createDecimalType; import static io.prestosql.spi.type.DoubleType.DOUBLE; import static io.prestosql.spi.type.IntegerType.INTEGER; import static io.prestosql.spi.type.VarcharType.createVarcharType; @State(Scope.Thread) -@Fork(0) +@Fork(1) @Threads(1) @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.MILLISECONDS) @@ -69,22 +69,17 @@ public class BenchmarkLimitOlkOperator .put("group5", ImmutableList.of(INTEGER, createVarcharType(16))) .put("group6", ImmutableList.of(INTEGER, BIGINT, createDecimalType(), DOUBLE)) .put("group7", ImmutableList.of(createVarcharType(20), createVarcharType(30), createVarcharType(50))) + .put("group8", ImmutableList.of(DATE)) .build(); - private static final Map> SORT_CHANNELS = ImmutableMap.>builder() - .put("group1", ImmutableList.of(0)).put("group2", ImmutableList.of(0)) - .put("group3", ImmutableList.of(0)).put("group4", ImmutableList.of(0)) - .put("group5", ImmutableList.of(0, 1)).put("group6", ImmutableList.of(0, 1, 2, 3)) - .put("group7", ImmutableList.of(0, 1, 2)).build(); - @State(Scope.Thread) public static class BenchmarkContext extends AbstractOlkOperatorBenchmarkContext { - @Param({"1", "100", "1000"}) + @Param({"100", "1000", "100000"}) private String limit = "100"; - @Param({"group1", "group2", "group3"}) + @Param({"group1", "group2", "group3", "group4", "group5", "group6", "group7", "group8"}) String testGroup = "group1"; @Param({"false", "true"}) @@ -96,18 +91,7 @@ public class BenchmarkLimitOlkOperator @Override protected List buildPages() { - List typesArray = INPUT_TYPES.get(testGroup); - List pages = new ArrayList<>(TOTAL_PAGES); - for (int i = 0; i < TOTAL_PAGES; i++) { - if (dictionaryBlocks) { - pages.add(PageBuilderUtil.createSequencePageWithDictionaryBlocks(typesArray, - Integer.parseInt(rowsPerPageStr))); - } - else { - pages.add(PageBuilderUtil.createSequencePage(typesArray, Integer.parseInt(rowsPerPageStr))); - } - } - return pages; + return buildPages(INPUT_TYPES.get(testGroup), TOTAL_PAGES, Integer.parseInt(rowsPerPageStr), dictionaryBlocks); } @Override diff --git a/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkLimitOmniOperator.java b/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkLimitOmniOperator.java index 6aca9f00ebfa0d0b903e5bdb482cc9cf52551f3f..bb248f1618ab60fbc161ecf60a6a632cf7635204 100644 --- a/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkLimitOmniOperator.java +++ b/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkLimitOmniOperator.java @@ -40,19 +40,19 @@ import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import org.openjdk.jmh.runner.options.VerboseMode; -import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.concurrent.TimeUnit; import static io.prestosql.spi.type.BigintType.BIGINT; +import static io.prestosql.spi.type.DateType.DATE; import static io.prestosql.spi.type.DecimalType.createDecimalType; import static io.prestosql.spi.type.DoubleType.DOUBLE; import static io.prestosql.spi.type.IntegerType.INTEGER; import static io.prestosql.spi.type.VarcharType.createVarcharType; @State(Scope.Thread) -@Fork(0) +@Fork(1) @Threads(1) @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.MILLISECONDS) @@ -69,22 +69,17 @@ public class BenchmarkLimitOmniOperator .put("group5", ImmutableList.of(INTEGER, createVarcharType(16))) .put("group6", ImmutableList.of(INTEGER, BIGINT, createDecimalType(), DOUBLE)) .put("group7", ImmutableList.of(createVarcharType(20), createVarcharType(30), createVarcharType(50))) + .put("group8", ImmutableList.of(DATE)) .build(); - private static final Map> SORT_CHANNELS = ImmutableMap.>builder() - .put("group1", ImmutableList.of(0)).put("group2", ImmutableList.of(0)) - .put("group3", ImmutableList.of(0)).put("group4", ImmutableList.of(0)) - .put("group5", ImmutableList.of(0, 1)).put("group6", ImmutableList.of(0, 1, 2, 3)) - .put("group7", ImmutableList.of(0, 1, 2)).build(); - @State(Scope.Thread) public static class BenchmarkContext extends AbstractOmniOperatorBenchmarkContext { - @Param({"1", "100", "1000"}) + @Param({"100", "1000", "100000"}) private String limit = "100"; - @Param({"group1", "group2", "group3"}) + @Param({"group1", "group2", "group3", "group4", "group5", "group6", "group7", "group8"}) String testGroup = "group1"; @Param({"false", "true"}) @@ -96,18 +91,7 @@ public class BenchmarkLimitOmniOperator @Override protected List buildPages() { - List typesArray = INPUT_TYPES.get(testGroup); - List pages = new ArrayList<>(TOTAL_PAGES); - for (int i = 0; i < TOTAL_PAGES; i++) { - if (dictionaryBlocks) { - pages.add(PageBuilderUtil.createSequencePageWithDictionaryBlocks(typesArray, - Integer.parseInt(rowsPerPageStr))); - } - else { - pages.add(PageBuilderUtil.createSequencePage(typesArray, Integer.parseInt(rowsPerPageStr))); - } - } - return pages; + return buildPages(INPUT_TYPES.get(testGroup), TOTAL_PAGES, Integer.parseInt(rowsPerPageStr), dictionaryBlocks); } @Override diff --git a/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkMergeOlkOperator.java b/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkMergeOlkOperator.java new file mode 100644 index 0000000000000000000000000000000000000000..3379fad54729776cc448372be5fe1cf22fcd02ff --- /dev/null +++ b/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkMergeOlkOperator.java @@ -0,0 +1,257 @@ +/* + * Copyright (C) 2020-2022. Huawei Technologies Co., Ltd. All rights reserved. + * Licensed 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 nova.hetu.olk.operator.benchmark; + +import com.google.common.cache.CacheBuilder; +import com.google.common.cache.CacheLoader; +import com.google.common.cache.LoadingCache; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import io.airlift.http.client.HttpClient; +import io.airlift.http.client.testing.TestingHttpClient; +import io.airlift.units.DataSize; +import io.prestosql.execution.Lifespan; +import io.prestosql.execution.TaskId; +import io.prestosql.execution.TaskStateMachine; +import io.prestosql.failuredetector.NoOpFailureDetector; +import io.prestosql.metadata.Split; +import io.prestosql.operator.DriverContext; +import io.prestosql.operator.ExchangeClientConfig; +import io.prestosql.operator.ExchangeClientFactory; +import io.prestosql.operator.ExchangeOperator; +import io.prestosql.operator.MergeOperator; +import io.prestosql.operator.MergeOperator.MergeOperatorFactory; +import io.prestosql.operator.TaskContext; +import io.prestosql.operator.TestingExchangeHttpClientHandler; +import io.prestosql.operator.TestingTaskBuffer; +import io.prestosql.spi.Page; +import io.prestosql.spi.plan.PlanNodeId; +import io.prestosql.spi.type.Type; +import io.prestosql.split.RemoteSplit; +import io.prestosql.sql.gen.OrderingCompiler; +import io.prestosql.testing.TestingSnapshotUtils; +import io.prestosql.testing.TestingTaskContext; +import nova.hetu.olk.tool.BlockUtils; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.BenchmarkMode; +import org.openjdk.jmh.annotations.Fork; +import org.openjdk.jmh.annotations.Level; +import org.openjdk.jmh.annotations.Measurement; +import org.openjdk.jmh.annotations.Mode; +import org.openjdk.jmh.annotations.OutputTimeUnit; +import org.openjdk.jmh.annotations.Param; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.Setup; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.annotations.TearDown; +import org.openjdk.jmh.annotations.Threads; +import org.openjdk.jmh.annotations.Warmup; +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.lang.reflect.Field; +import java.net.URI; +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.ScheduledThreadPoolExecutor; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; + +import static io.airlift.concurrent.Threads.daemonThreadsNamed; +import static io.airlift.units.DataSize.Unit.GIGABYTE; +import static io.prestosql.SessionTestUtils.TEST_SESSION; +import static io.prestosql.spi.block.SortOrder.ASC_NULLS_FIRST; +import static io.prestosql.spi.block.SortOrder.DESC_NULLS_FIRST; +import static io.prestosql.spi.type.BigintType.BIGINT; +import static io.prestosql.spi.type.DateType.DATE; +import static io.prestosql.spi.type.DecimalType.createDecimalType; +import static io.prestosql.spi.type.DoubleType.DOUBLE; +import static io.prestosql.spi.type.IntegerType.INTEGER; +import static io.prestosql.spi.type.VarcharType.createVarcharType; +import static java.util.concurrent.Executors.newScheduledThreadPool; +import static java.util.concurrent.Executors.newSingleThreadScheduledExecutor; + +@State(Scope.Thread) +@Fork(1) +@Threads(1) +@BenchmarkMode(Mode.AverageTime) +@OutputTimeUnit(TimeUnit.MILLISECONDS) +@Warmup(iterations = 3, time = 1) +@Measurement(iterations = 5, time = 1) +public class BenchmarkMergeOlkOperator +{ + public static final int TOTAL_PAGES = 100; + public static final int ROWS_PER_PAGE = 10000; + private static final String TASK = "task"; + + private static AtomicInteger operatorId = new AtomicInteger(); + private static final Map> INPUT_TYPES = ImmutableMap + .>builder().put("group1", ImmutableList.of(INTEGER, INTEGER, DOUBLE)) + .put("group2", ImmutableList.of(BIGINT, BIGINT)) + .put("group3", ImmutableList.of(DOUBLE, DOUBLE)) + .put("group4", ImmutableList.of(createVarcharType(16), createVarcharType(16))) + .put("group5", ImmutableList.of(createDecimalType(), createDecimalType())) + .put("group6", ImmutableList.of(createVarcharType(50), createVarcharType(50))) + .put("group7", ImmutableList.of(DATE, DATE)) + .build(); + + @State(Scope.Thread) + public static class BenchmarkContext + { + private ScheduledExecutorService executor; + private ScheduledExecutorService scheduledExecutor; + private HttpClient httpClient; + private ExchangeClientFactory exchangeClientFactory; + + private LoadingCache taskBuffers; + + private MergeOperatorFactory operatorFactory; + private TaskContext testingTaskContext; + private List pageTemplate; + + @Param({"group1", "group2", "group3", "group4", "group5", "group6", "group7"}) + String testGroup = "group1"; + + @Setup(Level.Trial) + public void setupTrial() + { + executor = newSingleThreadScheduledExecutor(daemonThreadsNamed("test-merge-omni-operator-%s")); + scheduledExecutor = newScheduledThreadPool(2, daemonThreadsNamed("test-scheduledExecutor-%s")); + pageTemplate = buildPages(); + } + + @Setup(Level.Invocation) + public void setupInvocation() + { + testingTaskContext = createTaskContext(); + taskBuffers = CacheBuilder.newBuilder().build(CacheLoader.from(TestingTaskBuffer::new)); + httpClient = new TestingHttpClient(new TestingExchangeHttpClientHandler(taskBuffers), executor); + exchangeClientFactory = new ExchangeClientFactory(new ExchangeClientConfig(), httpClient, + executor, new NoOpFailureDetector()); + operatorFactory = createOperatorFactory(); + } + + @TearDown(Level.Trial) + public void cleanupTrial() + { + executor.shutdownNow(); + executor = null; + scheduledExecutor.shutdownNow(); + scheduledExecutor = null; + + try { + Class cl = TestingSnapshotUtils.NOOP_SNAPSHOT_UTILS.getClass(); + Field field = cl.getDeclaredField("deleteSnapshotExecutor"); + field.setAccessible(true); + ScheduledThreadPoolExecutor snapshotExecutor = (ScheduledThreadPoolExecutor) field.get(TestingSnapshotUtils.NOOP_SNAPSHOT_UTILS); + snapshotExecutor.shutdownNow(); + } + catch (NoSuchFieldException | IllegalAccessException e) { + } + } + + @TearDown(Level.Invocation) + public void cleanupInvocation() + { + httpClient.close(); + httpClient = null; + exchangeClientFactory.stop(); + exchangeClientFactory = null; + taskBuffers.cleanUp(); + } + + protected List buildPages() + { + List typesArray = INPUT_TYPES.get(testGroup); + List pages = new ArrayList<>(); + for (int i = 0; i < TOTAL_PAGES; i++) { + pages.add(PageBuilderUtil.createSequencePage(typesArray, ROWS_PER_PAGE)); + } + return pages; + } + + protected MergeOperatorFactory createOperatorFactory() + { + List totalChannels = INPUT_TYPES.get(testGroup); + return new MergeOperatorFactory(operatorId.getAndIncrement(), + new PlanNodeId("test"), exchangeClientFactory, + new OrderingCompiler(), totalChannels, ImmutableList.of(0), + ImmutableList.of(0, 1), ImmutableList.of(ASC_NULLS_FIRST, DESC_NULLS_FIRST)); + } + + public TaskContext createTaskContext() + { + TaskContext testingTaskContext; + testingTaskContext = TestingTaskContext.builder(executor, scheduledExecutor, TEST_SESSION) + .setQueryMaxMemory(new DataSize(2, GIGABYTE)).setTaskStateMachine(new TaskStateMachine(new TaskId("query", 1, 1), executor)).build(); + return testingTaskContext; + } + + protected List getPages() + { + List slicedPages = new ArrayList<>(); + for (Page page : pageTemplate) { + slicedPages.add(page.getRegion(0, page.getPositionCount())); + } + return slicedPages; + } + } + + @Benchmark + public List merge(BenchmarkContext context) + { + DriverContext driverContext = context.testingTaskContext.addPipelineContext(0, true, true, false) + .addDriverContext(); + MergeOperator operator = (MergeOperator) context.operatorFactory.createOperator(driverContext); + operator.addSplit(new Split(ExchangeOperator.REMOTE_CONNECTOR_ID, + new RemoteSplit(URI.create("http://localhost/" + TASK), "new split test instance id"), + Lifespan.taskWide())); + operator.noMoreSplits(); + List pages = context.getPages(); + LinkedList outputPages = new LinkedList<>(); + context.taskBuffers.getUnchecked(TASK).addPages(pages, true); + + do { + Page outputPage = operator.getOutput(); + if (outputPage != null) { + outputPages.add(outputPage); + BlockUtils.freePage(outputPage); + } + } while (!operator.isFinished()); + if (pages != null) { + for (Page page : pages) { + BlockUtils.freePage(page); + } + } + operator.close(); + driverContext.finished(); + driverContext.getPipelineContext().getTaskContext().getTaskStateMachine().finished(); + return outputPages; + } + + public static void main(String[] args) throws RunnerException + { + Options options = new OptionsBuilder().verbosity(VerboseMode.NORMAL) + .include(".*" + BenchmarkMergeOlkOperator.class.getSimpleName() + ".*").build(); + new Runner(options).run(); + } +} diff --git a/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkMergeOmniOperator.java b/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkMergeOmniOperator.java new file mode 100644 index 0000000000000000000000000000000000000000..e015329d4ad914b64ef103d5f87f5940508dc8be --- /dev/null +++ b/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkMergeOmniOperator.java @@ -0,0 +1,264 @@ +/* + * Copyright (C) 2020-2022. Huawei Technologies Co., Ltd. All rights reserved. + * Licensed 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 nova.hetu.olk.operator.benchmark; + +import com.google.common.cache.CacheBuilder; +import com.google.common.cache.CacheLoader; +import com.google.common.cache.LoadingCache; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import io.airlift.http.client.HttpClient; +import io.airlift.http.client.testing.TestingHttpClient; +import io.airlift.units.DataSize; +import io.prestosql.execution.Lifespan; +import io.prestosql.execution.TaskId; +import io.prestosql.execution.TaskStateMachine; +import io.prestosql.failuredetector.NoOpFailureDetector; +import io.prestosql.metadata.Split; +import io.prestosql.operator.DriverContext; +import io.prestosql.operator.ExchangeClientConfig; +import io.prestosql.operator.ExchangeClientFactory; +import io.prestosql.operator.ExchangeOperator; +import io.prestosql.operator.TaskContext; +import io.prestosql.operator.TestingExchangeHttpClientHandler; +import io.prestosql.operator.TestingTaskBuffer; +import io.prestosql.spi.Page; +import io.prestosql.spi.plan.PlanNodeId; +import io.prestosql.spi.type.Type; +import io.prestosql.split.RemoteSplit; +import io.prestosql.sql.gen.OrderingCompiler; +import io.prestosql.testing.TestingPagesSerdeFactory; +import io.prestosql.testing.TestingSnapshotUtils; +import io.prestosql.testing.TestingTaskContext; +import nova.hetu.olk.operator.MergeOmniOperator; +import nova.hetu.olk.operator.MergeOmniOperator.MergeOmniOperatorFactory; +import nova.hetu.olk.tool.BlockUtils; +import nova.hetu.olk.tool.VecAllocatorHelper; +import nova.hetu.omniruntime.vector.VecAllocator; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.BenchmarkMode; +import org.openjdk.jmh.annotations.Fork; +import org.openjdk.jmh.annotations.Level; +import org.openjdk.jmh.annotations.Measurement; +import org.openjdk.jmh.annotations.Mode; +import org.openjdk.jmh.annotations.OutputTimeUnit; +import org.openjdk.jmh.annotations.Param; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.Setup; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.annotations.TearDown; +import org.openjdk.jmh.annotations.Threads; +import org.openjdk.jmh.annotations.Warmup; +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.lang.reflect.Field; +import java.net.URI; +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.ScheduledThreadPoolExecutor; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; + +import static io.airlift.concurrent.Threads.daemonThreadsNamed; +import static io.airlift.units.DataSize.Unit.GIGABYTE; +import static io.prestosql.SessionTestUtils.TEST_SESSION; +import static io.prestosql.spi.block.SortOrder.ASC_NULLS_FIRST; +import static io.prestosql.spi.block.SortOrder.DESC_NULLS_FIRST; +import static io.prestosql.spi.type.BigintType.BIGINT; +import static io.prestosql.spi.type.DateType.DATE; +import static io.prestosql.spi.type.DecimalType.createDecimalType; +import static io.prestosql.spi.type.DoubleType.DOUBLE; +import static io.prestosql.spi.type.IntegerType.INTEGER; +import static io.prestosql.spi.type.VarcharType.createVarcharType; +import static java.util.concurrent.Executors.newScheduledThreadPool; +import static java.util.concurrent.Executors.newSingleThreadScheduledExecutor; +import static nova.hetu.olk.tool.OperatorUtils.transferToOffHeapPages; + +@State(Scope.Thread) +@Fork(1) +@Threads(1) +@BenchmarkMode(Mode.AverageTime) +@OutputTimeUnit(TimeUnit.MILLISECONDS) +@Warmup(iterations = 3, time = 1) +@Measurement(iterations = 5, time = 1) +public class BenchmarkMergeOmniOperator +{ + public static final int TOTAL_PAGES = 100; + public static final int ROWS_PER_PAGE = 10000; + private static final String TASK = "task"; + + private static AtomicInteger operatorId = new AtomicInteger(); + private static final Map> INPUT_TYPES = ImmutableMap + .>builder().put("group1", ImmutableList.of(INTEGER, INTEGER)) + .put("group2", ImmutableList.of(BIGINT, BIGINT)) + .put("group3", ImmutableList.of(DOUBLE, DOUBLE)) + .put("group4", ImmutableList.of(createVarcharType(16), createVarcharType(16))) + .put("group5", ImmutableList.of(createDecimalType(), createDecimalType())) + .put("group6", ImmutableList.of(createVarcharType(50), createVarcharType(50))) + .put("group7", ImmutableList.of(DATE, DATE)) + .build(); + + @State(Scope.Thread) + public static class BenchmarkContext + { + private ScheduledExecutorService executor; + private ScheduledExecutorService scheduledExecutor; + private HttpClient httpClient; + private ExchangeClientFactory exchangeClientFactory; + + private LoadingCache taskBuffers; + + private MergeOmniOperatorFactory operatorFactory; + private TaskContext testingTaskContext; + private VecAllocator taskLevelAllocator; + private List pageTemplate; + + @Param({"group1", "group2", "group3", "group4", "group5", "group6", "group7"}) + String testGroup = "group1"; + + @Setup(Level.Trial) + public void setupTrial() + { + executor = newSingleThreadScheduledExecutor(daemonThreadsNamed("test-merge-omni-operator-%s")); + scheduledExecutor = newScheduledThreadPool(2, daemonThreadsNamed("test-scheduledExecutor-%s")); + pageTemplate = buildPages(); + } + + @Setup(Level.Invocation) + public void setupInvocation() + { + testingTaskContext = createTaskContext(); + taskBuffers = CacheBuilder.newBuilder().build(CacheLoader.from(TestingTaskBuffer::new)); + httpClient = new TestingHttpClient(new TestingExchangeHttpClientHandler(taskBuffers), executor); + exchangeClientFactory = new ExchangeClientFactory(new ExchangeClientConfig(), httpClient, + executor, new NoOpFailureDetector()); + operatorFactory = createOperatorFactory(); + } + + @TearDown(Level.Trial) + public void cleanupTrial() + { + executor.shutdownNow(); + executor = null; + scheduledExecutor.shutdownNow(); + scheduledExecutor = null; + + try { + Class cl = TestingSnapshotUtils.NOOP_SNAPSHOT_UTILS.getClass(); + Field field = cl.getDeclaredField("deleteSnapshotExecutor"); + field.setAccessible(true); + ScheduledThreadPoolExecutor snapshotExecutor = (ScheduledThreadPoolExecutor) field.get(TestingSnapshotUtils.NOOP_SNAPSHOT_UTILS); + snapshotExecutor.shutdownNow(); + } + catch (NoSuchFieldException | IllegalAccessException e) { + } + } + + @TearDown(Level.Invocation) + public void cleanupInvocation() + { + httpClient.close(); + httpClient = null; + exchangeClientFactory.stop(); + exchangeClientFactory = null; + taskBuffers.cleanUp(); + } + + protected List buildPages() + { + List typesArray = INPUT_TYPES.get(testGroup); + List pages = new ArrayList<>(); + for (int i = 0; i < TOTAL_PAGES; i++) { + pages.add(PageBuilderUtil.createSequencePage(typesArray, ROWS_PER_PAGE)); + } + return pages; + } + + protected MergeOmniOperatorFactory createOperatorFactory() + { + List totalChannels = INPUT_TYPES.get(testGroup); + return new MergeOmniOperatorFactory(operatorId.getAndIncrement(), + operatorId.getAndIncrement(), new PlanNodeId("test"), exchangeClientFactory, + new TestingPagesSerdeFactory(), new OrderingCompiler(), totalChannels, ImmutableList.of(0), + ImmutableList.of(0, 1), ImmutableList.of(ASC_NULLS_FIRST, DESC_NULLS_FIRST)); + } + + public TaskContext createTaskContext() + { + TaskContext testingTaskContext; + testingTaskContext = TestingTaskContext.builder(executor, scheduledExecutor, TEST_SESSION) + .setQueryMaxMemory(new DataSize(2, GIGABYTE)).setTaskStateMachine(new TaskStateMachine(new TaskId("query", 1, 1), executor)).build(); + taskLevelAllocator = VecAllocatorHelper.createTaskLevelAllocator(testingTaskContext); + return testingTaskContext; + } + + protected List getPages() + { + List slicedPages = new ArrayList<>(); + for (Page page : pageTemplate) { + slicedPages.add(page.getRegion(0, page.getPositionCount())); + } + return transferToOffHeapPages(taskLevelAllocator, slicedPages); + } + } + + @Benchmark + public List merge(BenchmarkContext context) + { + DriverContext driverContext = context.testingTaskContext.addPipelineContext(0, true, true, false) + .addDriverContext(); + MergeOmniOperator operator = (MergeOmniOperator) context.operatorFactory.createOperator(driverContext); + operator.addSplit(new Split(ExchangeOperator.REMOTE_CONNECTOR_ID, + new RemoteSplit(URI.create("http://localhost/" + TASK), "new split test instance id"), + Lifespan.taskWide())); + operator.noMoreSplits(); + List pages = context.getPages(); + LinkedList outputPages = new LinkedList<>(); + context.taskBuffers.getUnchecked(TASK).addPages(pages, true); + + do { + Page outputPage = operator.getOutput(); + if (outputPage != null) { + outputPages.add(outputPage); + BlockUtils.freePage(outputPage); + } + } while (!operator.isFinished()); + + if (pages != null) { + for (Page page : pages) { + BlockUtils.freePage(page); + } + } + operator.close(); + driverContext.finished(); + driverContext.getPipelineContext().getTaskContext().getTaskStateMachine().finished(); + return outputPages; + } + + public static void main(String[] args) throws RunnerException + { + Options options = new OptionsBuilder().verbosity(VerboseMode.NORMAL) + .include(".*" + BenchmarkMergeOmniOperator.class.getSimpleName() + ".*").build(); + new Runner(options).run(); + } +} diff --git a/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkOlkFilterAndProject.java b/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkOlkFilterAndProject.java index 2bc9fc4904e36ee1046bd856c96cf422e1397fe7..a9ad1986a0e7400f602303e930262a7213ec564f 100644 --- a/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkOlkFilterAndProject.java +++ b/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkOlkFilterAndProject.java @@ -70,7 +70,7 @@ import static org.openjdk.jmh.annotations.Level.Iteration; import static org.openjdk.jmh.annotations.Scope.Thread; @State(Thread) -@Fork(0) +@Fork(1) @Threads(1) @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.MILLISECONDS) diff --git a/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkOmniFilterAndProject.java b/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkOmniFilterAndProject.java index 0b8347b6348aae569414df75049ad8e5d5713e69..181c9c5ecda9ba4e7ed006a29e3a545004d5cabd 100644 --- a/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkOmniFilterAndProject.java +++ b/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkOmniFilterAndProject.java @@ -72,7 +72,7 @@ import static org.openjdk.jmh.annotations.Level.Iteration; import static org.openjdk.jmh.annotations.Scope.Thread; @State(Thread) -@Fork(0) +@Fork(1) @Threads(1) @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.MILLISECONDS) diff --git a/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkOrderByOlkOperator.java b/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkOrderByOlkOperator.java index 8a8cf77e048cab77cc6a70357c32c545ccce71ce..221673fa625ee84ce316756031f4264f23f0e075 100644 --- a/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkOrderByOlkOperator.java +++ b/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkOrderByOlkOperator.java @@ -51,11 +51,14 @@ import java.util.concurrent.TimeUnit; import static io.prestosql.spi.block.SortOrder.ASC_NULLS_FIRST; import static io.prestosql.spi.block.SortOrder.DESC_NULLS_FIRST; +import static io.prestosql.spi.type.BigintType.BIGINT; +import static io.prestosql.spi.type.DecimalType.createDecimalType; +import static io.prestosql.spi.type.DoubleType.DOUBLE; import static io.prestosql.spi.type.IntegerType.INTEGER; import static io.prestosql.spi.type.VarcharType.createVarcharType; @State(Scope.Thread) -@Fork(0) +@Fork(1) @Threads(1) @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.MILLISECONDS) @@ -69,16 +72,16 @@ public class BenchmarkOrderByOlkOperator private static final Map> INPUT_TYPES = ImmutableMap .>builder().put("group1", ImmutableList.of(createVarcharType(16))) .put("group2", ImmutableList.of(INTEGER, INTEGER)) - .put("group3", ImmutableList.of(INTEGER, INTEGER, INTEGER)) - .put("group4", ImmutableList.of(INTEGER, INTEGER)) + .put("group3", ImmutableList.of(INTEGER, INTEGER, DOUBLE)) + .put("group4", ImmutableList.of(INTEGER, BIGINT)) .put("group5", ImmutableList.of(createVarcharType(16))) - .put("group6", ImmutableList.of(INTEGER, INTEGER, INTEGER)) + .put("group6", ImmutableList.of(INTEGER, BIGINT, createDecimalType())) .put("group7", ImmutableList.of(createVarcharType(20), createVarcharType(30), createVarcharType(50))) .put("group8", ImmutableList.of(createVarcharType(50), INTEGER)) .put("group9", ImmutableList.of(INTEGER, createVarcharType(60), createVarcharType(20), createVarcharType(30))) .put("group10", - ImmutableList.of(INTEGER, createVarcharType(50), INTEGER, INTEGER, createVarcharType(50))) + ImmutableList.of(INTEGER, createVarcharType(50), INTEGER, DOUBLE, createVarcharType(50))) .build(); private static final Map> SORT_CHANNELS = new ImmutableMap.Builder>() @@ -115,17 +118,7 @@ public class BenchmarkOrderByOlkOperator @Override protected List buildPages() { - List typesArray = INPUT_TYPES.get(testGroup); - List pages = new ArrayList<>(); - for (int i = 0; i < TOTAL_PAGES; i++) { - if (dictionaryBlocks) { - pages.add(PageBuilderUtil.createSequencePageWithDictionaryBlocks(typesArray, ROWS_PER_PAGE)); - } - else { - pages.add(PageBuilderUtil.createSequencePage(typesArray, ROWS_PER_PAGE)); - } - } - return pages; + return buildPages(INPUT_TYPES.get(testGroup), TOTAL_PAGES, ROWS_PER_PAGE, dictionaryBlocks); } @Override diff --git a/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkOrderByOmniOperator.java b/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkOrderByOmniOperator.java index 067147eda1d4504cf0b57de30488c2acd6371c7d..88727921fafef3a1732cd3b1e41492495bae39e7 100644 --- a/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkOrderByOmniOperator.java +++ b/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkOrderByOmniOperator.java @@ -47,12 +47,15 @@ import java.util.concurrent.TimeUnit; import static io.prestosql.spi.block.SortOrder.ASC_NULLS_FIRST; import static io.prestosql.spi.block.SortOrder.DESC_NULLS_FIRST; +import static io.prestosql.spi.type.BigintType.BIGINT; +import static io.prestosql.spi.type.DecimalType.createDecimalType; +import static io.prestosql.spi.type.DoubleType.DOUBLE; import static io.prestosql.spi.type.IntegerType.INTEGER; import static io.prestosql.spi.type.VarcharType.createVarcharType; import static nova.hetu.olk.operator.OrderByOmniOperator.OrderByOmniOperatorFactory.createOrderByOmniOperatorFactory; @State(Scope.Thread) -@Fork(0) +@Fork(1) @Threads(1) @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.MILLISECONDS) @@ -66,16 +69,16 @@ public class BenchmarkOrderByOmniOperator private static final Map> INPUT_TYPES = ImmutableMap .>builder().put("group1", ImmutableList.of(createVarcharType(16))) .put("group2", ImmutableList.of(INTEGER, INTEGER)) - .put("group3", ImmutableList.of(INTEGER, INTEGER, INTEGER)) - .put("group4", ImmutableList.of(INTEGER, INTEGER)) + .put("group3", ImmutableList.of(INTEGER, INTEGER, DOUBLE)) + .put("group4", ImmutableList.of(INTEGER, BIGINT)) .put("group5", ImmutableList.of(createVarcharType(16))) - .put("group6", ImmutableList.of(INTEGER, INTEGER, INTEGER)) + .put("group6", ImmutableList.of(INTEGER, BIGINT, createDecimalType())) .put("group7", ImmutableList.of(createVarcharType(20), createVarcharType(30), createVarcharType(50))) .put("group8", ImmutableList.of(createVarcharType(50), INTEGER)) .put("group9", ImmutableList.of(INTEGER, createVarcharType(60), createVarcharType(20), createVarcharType(30))) .put("group10", - ImmutableList.of(INTEGER, createVarcharType(50), INTEGER, INTEGER, createVarcharType(50))) + ImmutableList.of(INTEGER, createVarcharType(50), INTEGER, DOUBLE, createVarcharType(50))) .build(); private static final Map> SORT_CHANNELS = new ImmutableMap.Builder>() @@ -111,17 +114,7 @@ public class BenchmarkOrderByOmniOperator @Override protected List buildPages() { - List typesArray = INPUT_TYPES.get(testGroup); - List pages = new ArrayList<>(); - for (int i = 0; i < TOTAL_PAGES; i++) { - if (dictionaryBlocks) { - pages.add(PageBuilderUtil.createSequencePageWithDictionaryBlocks(typesArray, ROWS_PER_PAGE)); - } - else { - pages.add(PageBuilderUtil.createSequencePage(typesArray, ROWS_PER_PAGE)); - } - } - return pages; + return buildPages(INPUT_TYPES.get(testGroup), TOTAL_PAGES, ROWS_PER_PAGE, dictionaryBlocks); } @Override diff --git a/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkRunner.java b/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkRunner.java index e3f16b7e78c0692f3a82a53515f33f9096f4fe60..d7d10276f67588806ee242c55f535ed603fed1de 100644 --- a/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkRunner.java +++ b/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkRunner.java @@ -16,13 +16,18 @@ package nova.hetu.olk.operator.benchmark; import org.apache.commons.io.FileUtils; +import org.junit.Ignore; import org.openjdk.jmh.results.format.ResultFormatType; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import org.openjdk.jmh.runner.options.VerboseMode; +import org.testng.annotations.Test; +import java.io.BufferedReader; import java.io.File; +import java.io.FileReader; +import java.net.URL; public class BenchmarkRunner { @@ -45,13 +50,31 @@ public class BenchmarkRunner FileUtils.forceMkdir(new File("benchmark-result")); String benchmarkName = benchmarkClassName.replaceAll("\\.java", ""); Options options = new OptionsBuilder().verbosity(VerboseMode.NORMAL) - .include(".*" + benchmarkName + ".*") + .include("nova.hetu.olk.operator.benchmark." + benchmarkName + ".*") .shouldDoGC(true) .resultFormat(ResultFormatType.CSV) .result(System.getProperty("user.dir") + "/benchmark-result/" + benchmarkName + ".csv") - .forks(0) .build(); new Runner(options).run(); - System.exit(0); + } + + @Test(timeOut = -1) + @Ignore + public void benchmarkRes() + { + URL url = getClass().getClassLoader().getResource("operator.ini"); + File file = new File(url.getFile()); + try (BufferedReader bufferedReader = new BufferedReader(new FileReader(file))) { + String operator; + while ((operator = bufferedReader.readLine()) != null) { + if (operator.contains("#") || operator.contains("//")) { + continue; + } + runBenchmark(operator); + } + } + catch (Exception e) { + System.out.println(e); + } } } diff --git a/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkTopNOlkOperator.java b/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkTopNOlkOperator.java index 571f56ea6b0034012b436b686c07621eef5df296..6e81b802bb30659cef4e91e60d5753c8c139d199 100644 --- a/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkTopNOlkOperator.java +++ b/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkTopNOlkOperator.java @@ -47,11 +47,13 @@ import java.util.Map; import java.util.concurrent.TimeUnit; import static io.prestosql.spi.type.BigintType.BIGINT; +import static io.prestosql.spi.type.DecimalType.createDecimalType; +import static io.prestosql.spi.type.DoubleType.DOUBLE; import static io.prestosql.spi.type.IntegerType.INTEGER; import static io.prestosql.spi.type.VarcharType.createVarcharType; @State(Scope.Thread) -@Fork(0) +@Fork(1) @Threads(1) @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.MILLISECONDS) @@ -65,22 +67,24 @@ public class BenchmarkTopNOlkOperator .>builder().put("group1", ImmutableList.of(createVarcharType(16))) .put("group2", ImmutableList.of(INTEGER, INTEGER)) .put("group3", ImmutableList.of(INTEGER, INTEGER, INTEGER)) - .put("group4", ImmutableList.of(BIGINT, INTEGER)).put("group5", ImmutableList.of(createVarcharType(16))) - .put("group6", ImmutableList.of(INTEGER, INTEGER, INTEGER)) + .put("group4", ImmutableList.of(BIGINT)).put("group5", ImmutableList.of(DOUBLE)) + .put("group6", ImmutableList.of(INTEGER, DOUBLE, BIGINT)) .put("group7", ImmutableList.of(createVarcharType(20), createVarcharType(30), createVarcharType(50))) - .put("group8", ImmutableList.of(createVarcharType(50), INTEGER)) + .put("group8", ImmutableList.of(createDecimalType())) .put("group9", ImmutableList.of(INTEGER, createVarcharType(60), createVarcharType(20), createVarcharType(30))) .put("group10", - ImmutableList.of(INTEGER, createVarcharType(50), INTEGER, INTEGER, createVarcharType(50))) + ImmutableList.of(INTEGER, createVarcharType(50), INTEGER, DOUBLE, createVarcharType(50))) + .put("group11", ImmutableList.of(BIGINT, DOUBLE)).put("group12", ImmutableList.of(BIGINT, createDecimalType())) .build(); private static final Map> SORT_CHANNELS = ImmutableMap.>builder() .put("group1", ImmutableList.of(0)).put("group2", ImmutableList.of(0, 1)) - .put("group3", ImmutableList.of(0, 1, 2)).put("group4", ImmutableList.of(0, 1)) + .put("group3", ImmutableList.of(0, 1, 2)).put("group4", ImmutableList.of(0)) .put("group5", ImmutableList.of(0)).put("group6", ImmutableList.of(0, 1, 2)) - .put("group7", ImmutableList.of(0, 1, 2)).put("group8", ImmutableList.of(0, 1)) - .put("group9", ImmutableList.of(0, 1, 2, 3)).put("group10", ImmutableList.of(0, 1, 2, 3)).build(); + .put("group7", ImmutableList.of(0, 1, 2)).put("group8", ImmutableList.of(0)) + .put("group9", ImmutableList.of(0, 1, 2, 3)).put("group10", ImmutableList.of(0, 1, 2, 3, 4)) + .put("group11", ImmutableList.of(0, 1)).put("group12", ImmutableList.of(0, 1)).build(); @State(Scope.Thread) public static class BenchmarkContext @@ -89,7 +93,7 @@ public class BenchmarkTopNOlkOperator @Param({"1", "10", "100", "1000", "10000"}) private String topN = "100"; - @Param({"group1", "group2", "group3", "group4", "group5", "group6", "group7", "group8", "group9", "group10"}) + @Param({"group1", "group2", "group3", "group4", "group5", "group6", "group7", "group8", "group9", "group10", "group11", "group12"}) String testGroup = "group1"; @Param({"false", "true"}) @@ -108,18 +112,7 @@ public class BenchmarkTopNOlkOperator @Override protected List buildPages() { - List typesArray = INPUT_TYPES.get(testGroup); - List pages = new ArrayList<>(); - for (int i = 0; i < TOTAL_PAGES; i++) { - if (dictionaryBlocks) { - pages.add(PageBuilderUtil.createSequencePageWithDictionaryBlocks(typesArray, - Integer.parseInt(rowsPerPageStr))); - } - else { - pages.add(PageBuilderUtil.createSequencePage(typesArray, Integer.parseInt(rowsPerPageStr))); - } - } - return pages; + return buildPages(INPUT_TYPES.get(testGroup), TOTAL_PAGES, Integer.parseInt(rowsPerPageStr), dictionaryBlocks); } @Override @@ -144,10 +137,6 @@ public class BenchmarkTopNOlkOperator public static void main(String[] args) throws RunnerException { - BenchmarkContext data = new BenchmarkContext(); - data.setup(); - new BenchmarkTopNOlkOperator().topN(data); - Options options = new OptionsBuilder().verbosity(VerboseMode.NORMAL) .include(".*" + BenchmarkTopNOlkOperator.class.getSimpleName() + ".*").build(); diff --git a/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkTopNOmniOperator.java b/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkTopNOmniOperator.java index 4b2d813d39a10b2cf996f1614ea938c492d7ef49..6493c95575479f2fa9f70bb2d2e611a901a59803 100644 --- a/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkTopNOmniOperator.java +++ b/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkTopNOmniOperator.java @@ -47,11 +47,13 @@ import java.util.Map; import java.util.concurrent.TimeUnit; import static io.prestosql.spi.type.BigintType.BIGINT; +import static io.prestosql.spi.type.DecimalType.createDecimalType; +import static io.prestosql.spi.type.DoubleType.DOUBLE; import static io.prestosql.spi.type.IntegerType.INTEGER; import static io.prestosql.spi.type.VarcharType.createVarcharType; @State(Scope.Thread) -@Fork(0) +@Fork(1) @Threads(1) @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.MILLISECONDS) @@ -65,22 +67,24 @@ public class BenchmarkTopNOmniOperator .>builder().put("group1", ImmutableList.of(createVarcharType(16))) .put("group2", ImmutableList.of(INTEGER, INTEGER)) .put("group3", ImmutableList.of(INTEGER, INTEGER, INTEGER)) - .put("group4", ImmutableList.of(BIGINT, INTEGER)).put("group5", ImmutableList.of(createVarcharType(16))) - .put("group6", ImmutableList.of(INTEGER, INTEGER, INTEGER)) + .put("group4", ImmutableList.of(BIGINT)).put("group5", ImmutableList.of(DOUBLE)) + .put("group6", ImmutableList.of(INTEGER, DOUBLE, BIGINT)) .put("group7", ImmutableList.of(createVarcharType(20), createVarcharType(30), createVarcharType(50))) - .put("group8", ImmutableList.of(createVarcharType(50), INTEGER)) + .put("group8", ImmutableList.of(createDecimalType())) .put("group9", ImmutableList.of(INTEGER, createVarcharType(60), createVarcharType(20), createVarcharType(30))) .put("group10", - ImmutableList.of(INTEGER, createVarcharType(50), INTEGER, INTEGER, createVarcharType(50))) + ImmutableList.of(INTEGER, createVarcharType(50), INTEGER, DOUBLE, createVarcharType(50))) + .put("group11", ImmutableList.of(BIGINT, DOUBLE)).put("group12", ImmutableList.of(BIGINT, createDecimalType())) .build(); private static final Map> SORT_CHANNELS = ImmutableMap.>builder() .put("group1", ImmutableList.of(0)).put("group2", ImmutableList.of(0, 1)) - .put("group3", ImmutableList.of(0, 1, 2)).put("group4", ImmutableList.of(0, 1)) + .put("group3", ImmutableList.of(0, 1, 2)).put("group4", ImmutableList.of(0)) .put("group5", ImmutableList.of(0)).put("group6", ImmutableList.of(0, 1, 2)) - .put("group7", ImmutableList.of(0, 1, 2)).put("group8", ImmutableList.of(0, 1)) - .put("group9", ImmutableList.of(0, 1, 2, 3)).put("group10", ImmutableList.of(0, 1, 2, 3)).build(); + .put("group7", ImmutableList.of(0, 1, 2)).put("group8", ImmutableList.of(0)) + .put("group9", ImmutableList.of(0, 1, 2, 3)).put("group10", ImmutableList.of(0, 1, 2, 3, 4)) + .put("group11", ImmutableList.of(0, 1)).put("group12", ImmutableList.of(0, 1)).build(); @State(Scope.Thread) public static class BenchmarkContext @@ -89,7 +93,7 @@ public class BenchmarkTopNOmniOperator @Param({"1", "10", "100", "1000", "10000"}) private String topN = "100"; - @Param({"group1", "group2", "group3", "group4", "group5", "group6", "group7", "group8", "group9", "group10"}) + @Param({"group1", "group2", "group3", "group4", "group5", "group6", "group7", "group8", "group9", "group10", "group11", "group12"}) String testGroup = "group1"; @Param({"false", "true"}) @@ -101,18 +105,7 @@ public class BenchmarkTopNOmniOperator @Override protected List buildPages() { - List typesArray = INPUT_TYPES.get(testGroup); - List pages = new ArrayList<>(); - for (int i = 0; i < TOTAL_PAGES; i++) { - if (dictionaryBlocks) { - pages.add(PageBuilderUtil.createSequencePageWithDictionaryBlocks(typesArray, - Integer.parseInt(rowsPerPageStr))); - } - else { - pages.add(PageBuilderUtil.createSequencePage(typesArray, Integer.parseInt(rowsPerPageStr))); - } - } - return pages; + return buildPages(INPUT_TYPES.get(testGroup), TOTAL_PAGES, Integer.parseInt(rowsPerPageStr), dictionaryBlocks); } @Override @@ -138,10 +131,6 @@ public class BenchmarkTopNOmniOperator public static void main(String[] args) throws RunnerException { - BenchmarkContext data = new BenchmarkContext(); - data.setup(); - new BenchmarkTopNOmniOperator().topN(data); - Options options = new OptionsBuilder().verbosity(VerboseMode.NORMAL) .include(".*" + BenchmarkTopNOmniOperator.class.getSimpleName() + ".*").build(); diff --git a/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkWindowOlkOperator.java b/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkWindowOlkOperator.java index 4ad2f46595ab0e7a7fc317d8a8d0a8afca6c1e38..e1790bd551aa7c071d0f931e479694b7d3abbdc1 100644 --- a/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkWindowOlkOperator.java +++ b/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkWindowOlkOperator.java @@ -70,7 +70,7 @@ import static io.prestosql.spi.type.VarcharType.createVarcharType; import static org.openjdk.jmh.annotations.Scope.Thread; @State(Scope.Thread) -@Fork(0) +@Fork(1) @Threads(1) @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.MILLISECONDS) @@ -142,8 +142,8 @@ public class BenchmarkWindowOlkOperator private static final Map> PARTITION_CHANNELS = ImmutableMap .>builder().put("group1", ImmutableList.of(0, 1)) .put("group2", ImmutableList.of(0, 1, 2)).put("group3", ImmutableList.of(0, 1, 2, 3, 4)) - .put("group4", ImmutableList.of(0, 1, 2, 3)).put("group5", ImmutableList.of(1)) - .put("group6", ImmutableList.of(1)).put("group7", ImmutableList.of(0, 2, 3, 4)).build(); + .put("group4", ImmutableList.of(0, 1, 2, 3)).put("group5", ImmutableList.of(0, 1)) + .put("group6", ImmutableList.of(0, 1)).put("group7", ImmutableList.of(0, 1, 3, 4)).build(); private static final Map> INPUT_TYPES = ImmutableMap .>builder().put("group1", ImmutableList.of(BIGINT, BIGINT, BIGINT, BIGINT)) .put("group2", ImmutableList.of(BIGINT, BIGINT, BIGINT, BIGINT)) @@ -157,7 +157,6 @@ public class BenchmarkWindowOlkOperator .put("group7", ImmutableList.of(createVarcharType(50), createVarcharType(50), createVarcharType(50), createVarcharType(50), createVarcharType(50), INTEGER, BIGINT)) .build(); - private static final Map> WINDOW_TYPES = ImmutableMap .>builder().put("group1", ROW_NUMBER) .put("group2", COUNT_BIGINT_GROUP2).put("group3", AVG_BIGINT_GROUP3).put("group4", RANK) @@ -178,27 +177,13 @@ public class BenchmarkWindowOlkOperator @Param({"false", "true"}) boolean dictionaryBlocks; - public int rowsPerPartition; - - @Param("0") + @Param({"0", "1", "2"}) public int numberOfPregroupedColumns; - public int partitionsPerGroup; - @Override protected List buildPages() { - List typesArray = INPUT_TYPES.get(testGroup); - List pages = new ArrayList<>(); - for (int i = 0; i < TOTAL_PAGES; i++) { - if (dictionaryBlocks) { - pages.add(PageBuilderUtil.createSequencePageWithDictionaryBlocks(typesArray, ROWS_PER_PAGE)); - } - else { - pages.add(PageBuilderUtil.createSequencePage(typesArray, ROWS_PER_PAGE)); - } - } - return pages; + return buildPages(INPUT_TYPES.get(testGroup), TOTAL_PAGES, ROWS_PER_PAGE, dictionaryBlocks); } @Override diff --git a/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkWindowOmniOperator.java b/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkWindowOmniOperator.java index 6fac660143ddf044a5af4f2a1e5ec8061362556a..17d95182818a7ad5eb9783b422885279b4810ab7 100644 --- a/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkWindowOmniOperator.java +++ b/omnioperator/omniop-openlookeng-extension/src/test/java/nova/hetu/olk/operator/benchmark/BenchmarkWindowOmniOperator.java @@ -72,7 +72,7 @@ import static io.prestosql.spi.type.VarcharType.createVarcharType; import static org.openjdk.jmh.annotations.Scope.Thread; @State(Scope.Thread) -@Fork(0) +@Fork(1) @Threads(1) @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.MILLISECONDS) @@ -143,8 +143,8 @@ public class BenchmarkWindowOmniOperator private static final Map> PARTITION_CHANNELS = ImmutableMap .>builder().put("group1", ImmutableList.of(0, 1)) .put("group2", ImmutableList.of(0, 1, 2)).put("group3", ImmutableList.of(0, 1, 2, 3, 4)) - .put("group4", ImmutableList.of(0, 1, 2, 3)).put("group5", ImmutableList.of(1)) - .put("group6", ImmutableList.of(1)).put("group7", ImmutableList.of(0, 2, 3, 4)).build(); + .put("group4", ImmutableList.of(0, 1, 2, 3)).put("group5", ImmutableList.of(0, 1)) + .put("group6", ImmutableList.of(0, 1)).put("group7", ImmutableList.of(0, 1, 3, 4)).build(); private static final Map> INPUT_TYPES = ImmutableMap .>builder().put("group1", ImmutableList.of(BIGINT, BIGINT, BIGINT, BIGINT)) .put("group2", ImmutableList.of(BIGINT, BIGINT, BIGINT, BIGINT)) @@ -178,13 +178,9 @@ public class BenchmarkWindowOmniOperator @Param({"false", "true"}) boolean dictionaryBlocks; - public int rowsPerPartition; - - @Param("0") + @Param({"0", "1", "2"}) public int numberOfPregroupedColumns; - public int partitionsPerGroup; - public static WindowOmniOperator.WindowOmniOperatorFactory createFactoryUnbounded( List sourceTypes, List outputChannels, List functions, List partitionChannels, @@ -199,17 +195,7 @@ public class BenchmarkWindowOmniOperator @Override protected List buildPages() { - List typesArray = INPUT_TYPES.get(testGroup); - List pages = new ArrayList<>(); - for (int i = 0; i < TOTAL_PAGES; i++) { - if (dictionaryBlocks) { - pages.add(PageBuilderUtil.createSequencePageWithDictionaryBlocks(typesArray, ROWS_PER_PAGE)); - } - else { - pages.add(PageBuilderUtil.createSequencePage(typesArray, ROWS_PER_PAGE)); - } - } - return pages; + return buildPages(INPUT_TYPES.get(testGroup), TOTAL_PAGES, ROWS_PER_PAGE, dictionaryBlocks); } @Override diff --git a/omnioperator/omniop-openlookeng-extension/src/test/resources/operator.ini b/omnioperator/omniop-openlookeng-extension/src/test/resources/operator.ini new file mode 100644 index 0000000000000000000000000000000000000000..ea994f0ff3cceb091859cc916f72ffb0017b7d70 --- /dev/null +++ b/omnioperator/omniop-openlookeng-extension/src/test/resources/operator.ini @@ -0,0 +1,24 @@ +BenchmarkAggregationOlkOperator +BenchmarkAggregationOmniOperator +BenchmarkBuildOffHeapOmniOperator +BenchmarkBuildOnHeapOmniOperator +BenchmarkDistinctLimitOlkOperator +BenchmarkDistinctLimitOmniOperator +BenchmarkEnforceSingleRowOlkOperator +BenchmarkEnforceSingleRowOmniOperator +BenchmarkFilterAndProjectOlkOperator +BenchmarkFilterAndProjectOmniOperator +#BenchmarkHashAggregationOlkOperator +#BenchmarkHashAggregationOmniOperator +#BenchmarkHashJoinOlkOperator +#BenchmarkHashJoinOmniOperator +BenchmarkLimitOlkOperator +BenchmarkLimitOmniOperator +BenchmarkMergeOlkOperator +BenchmarkMergeOmniOperator +BenchmarkOrderByOlkOperator +BenchmarkOrderByOmniOperator +BenchmarkTopNOlkOperator +BenchmarkTopNOmniOperator +BenchmarkWindowOlkOperator +BenchmarkWindowOmniOperator \ No newline at end of file