Search in sources :

Example 91 with Setup

use of org.openjdk.jmh.annotations.Setup in project crate by crate.

the class AggregateCollectorBenchmark method setup.

@Setup
public void setup() {
    InputCollectExpression inExpr0 = new InputCollectExpression(0);
    Functions functions = new ModulesBuilder().add(new AggregationImplModule()).createInjector().getInstance(Functions.class);
    SumAggregation<?> sumAggregation = (SumAggregation<?>) functions.getQualified(Signature.aggregate(SumAggregation.NAME, DataTypes.INTEGER.getTypeSignature(), DataTypes.LONG.getTypeSignature()), List.of(DataTypes.INTEGER), DataTypes.INTEGER);
    var memoryManager = new OnHeapMemoryManager(bytes -> {
    });
    collector = new AggregateCollector(Collections.singletonList(inExpr0), RamAccounting.NO_ACCOUNTING, memoryManager, Version.CURRENT, AggregateMode.ITER_FINAL, new AggregationFunction[] { sumAggregation }, Version.CURRENT, new Input[][] { { inExpr0 } }, new Input[] { Literal.BOOLEAN_TRUE });
}
Also used : Input(io.crate.data.Input) InputCollectExpression(io.crate.execution.engine.collect.InputCollectExpression) OnHeapMemoryManager(io.crate.memory.OnHeapMemoryManager) SumAggregation(io.crate.execution.engine.aggregation.impl.SumAggregation) Functions(io.crate.metadata.Functions) ModulesBuilder(org.elasticsearch.common.inject.ModulesBuilder) AggregationImplModule(io.crate.execution.engine.aggregation.impl.AggregationImplModule) Setup(org.openjdk.jmh.annotations.Setup)

Example 92 with Setup

use of org.openjdk.jmh.annotations.Setup in project crate by crate.

the class GroupingStringCollectorBenchmark method createGroupingCollector.

@Setup
public void createGroupingCollector() {
    Functions functions = new ModulesBuilder().add(new AggregationImplModule()).createInjector().getInstance(Functions.class);
    groupByMinCollector = createGroupByMinBytesRefCollector(functions);
    memoryManager = new OnHeapMemoryManager(bytes -> {
    });
    List<String> keys = new ArrayList<>(Locale.getISOCountries().length);
    keys.addAll(Arrays.asList(Locale.getISOCountries()));
    rows = new ArrayList<>(20_000_000);
    for (int i = 0; i < 20_000_000; i++) {
        rows.add(new Row1(keys.get(i % keys.size())));
    }
}
Also used : Input(io.crate.data.Input) MinimumAggregation(io.crate.execution.engine.aggregation.impl.MinimumAggregation) BenchmarkMode(org.openjdk.jmh.annotations.BenchmarkMode) Arrays(java.util.Arrays) AggregationImplModule(io.crate.execution.engine.aggregation.impl.AggregationImplModule) Blackhole(org.openjdk.jmh.infra.Blackhole) SENTINEL(io.crate.data.SentinelRow.SENTINEL) CollectExpression(io.crate.execution.engine.collect.CollectExpression) BatchIterator(io.crate.data.BatchIterator) Scope(org.openjdk.jmh.annotations.Scope) ArrayList(java.util.ArrayList) Functions(io.crate.metadata.Functions) OutputTimeUnit(org.openjdk.jmh.annotations.OutputTimeUnit) Locale(java.util.Locale) Setup(org.openjdk.jmh.annotations.Setup) Mode(org.openjdk.jmh.annotations.Mode) InMemoryBatchIterator(io.crate.data.InMemoryBatchIterator) Signature(io.crate.metadata.functions.Signature) State(org.openjdk.jmh.annotations.State) RamAccounting(io.crate.breaker.RamAccounting) InputCollectExpression(io.crate.execution.engine.collect.InputCollectExpression) Benchmark(org.openjdk.jmh.annotations.Benchmark) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) BatchIterators(io.crate.data.BatchIterators) Version(org.elasticsearch.Version) Row(io.crate.data.Row) Literal(io.crate.expression.symbol.Literal) AggregateMode(io.crate.expression.symbol.AggregateMode) DataTypes(io.crate.types.DataTypes) OnHeapMemoryManager(io.crate.memory.OnHeapMemoryManager) ModulesBuilder(org.elasticsearch.common.inject.ModulesBuilder) Collections(java.util.Collections) Row1(io.crate.data.Row1) Row1(io.crate.data.Row1) OnHeapMemoryManager(io.crate.memory.OnHeapMemoryManager) ArrayList(java.util.ArrayList) Functions(io.crate.metadata.Functions) ModulesBuilder(org.elasticsearch.common.inject.ModulesBuilder) AggregationImplModule(io.crate.execution.engine.aggregation.impl.AggregationImplModule) Setup(org.openjdk.jmh.annotations.Setup)

Example 93 with Setup

use of org.openjdk.jmh.annotations.Setup in project crate by crate.

the class CsvReaderBenchmark method create_temp_file_and_uri.

@Setup
public void create_temp_file_and_uri() throws IOException {
    NodeContext nodeCtx = new NodeContext(new Functions(Map.of()));
    inputFactory = new InputFactory(nodeCtx);
    tempFile = File.createTempFile("temp", null);
    fileUri = tempFile.toURI().getPath();
    try (OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(tempFile), StandardCharsets.UTF_8)) {
        writer.write("name,id\n");
        writer.write("Arthur,4\n");
        writer.write("Trillian,5\n");
        writer.write("Emma,5\n");
        writer.write("Emily,9\n");
        writer.write("Sarah,5\n");
        writer.write("John,5\n");
        writer.write("Mical,9\n");
        writer.write("Mary,5\n");
        writer.write("Jimmy,9\n");
        writer.write("Tom,5\n");
        writer.write("Neil,0\n");
        writer.write("Rose,5\n");
        writer.write("Gobnait,5\n");
        writer.write("Rory,1\n");
        writer.write("Martin,11\n");
        writer.write("Arthur,4\n");
        writer.write("Trillian,5\n");
        writer.write("Emma,5\n");
        writer.write("Emily,9\n");
        writer.write("Sarah,5\n");
        writer.write("John,5\n");
        writer.write("Mical,9\n");
        writer.write("Mary,5\n");
        writer.write("Jimmy,9\n");
        writer.write("Tom,5\n");
        writer.write("Neil,0\n");
        writer.write("Rose,5\n");
        writer.write("Gobnait,5\n");
        writer.write("Rory,1\n");
        writer.write("Martin,11\n");
    }
}
Also used : LocalFsFileInputFactory(io.crate.execution.engine.collect.files.LocalFsFileInputFactory) InputFactory(io.crate.expression.InputFactory) NodeContext(io.crate.metadata.NodeContext) FileOutputStream(java.io.FileOutputStream) Functions(io.crate.metadata.Functions) OutputStreamWriter(java.io.OutputStreamWriter) Setup(org.openjdk.jmh.annotations.Setup)

Example 94 with Setup

use of org.openjdk.jmh.annotations.Setup in project crate by crate.

the class HyperLogLogDistinctAggregationBenchmark method setUp.

@Setup
public void setUp() throws Exception {
    hash = new MurmurHash3.Hash128();
    final InputCollectExpression inExpr0 = new InputCollectExpression(0);
    Functions functions = new ModulesBuilder().add(new ExtraFunctionsModule()).createInjector().getInstance(Functions.class);
    final HyperLogLogDistinctAggregation hllAggregation = (HyperLogLogDistinctAggregation) functions.getQualified(Signature.aggregate(HyperLogLogDistinctAggregation.NAME, DataTypes.STRING.getTypeSignature(), DataTypes.LONG.getTypeSignature()), List.of(DataTypes.STRING), DataTypes.STRING);
    onHeapMemoryManager = new OnHeapMemoryManager(bytes -> {
    });
    offHeapMemoryManager = new OffHeapMemoryManager();
    hyperLogLogPlusPlus = new HyperLogLogPlusPlus(HyperLogLogPlusPlus.DEFAULT_PRECISION, onHeapMemoryManager::allocate);
    onHeapCollector = new AggregateCollector(Collections.singletonList(inExpr0), RamAccounting.NO_ACCOUNTING, onHeapMemoryManager, Version.CURRENT, AggregateMode.ITER_FINAL, new AggregationFunction[] { hllAggregation }, Version.CURRENT, new Input[][] { { inExpr0 } }, new Input[] { Literal.BOOLEAN_TRUE });
    offHeapCollector = new AggregateCollector(Collections.singletonList(inExpr0), RamAccounting.NO_ACCOUNTING, offHeapMemoryManager, Version.CURRENT, AggregateMode.ITER_FINAL, new AggregationFunction[] { hllAggregation }, Version.CURRENT, new Input[][] { { inExpr0 } }, new Input[] { Literal.BOOLEAN_TRUE });
}
Also used : IntStream(java.util.stream.IntStream) Input(io.crate.data.Input) OffHeapMemoryManager(io.crate.memory.OffHeapMemoryManager) BenchmarkMode(org.openjdk.jmh.annotations.BenchmarkMode) Scope(org.openjdk.jmh.annotations.Scope) Warmup(org.openjdk.jmh.annotations.Warmup) Function(java.util.function.Function) ExtraFunctionsModule(io.crate.module.ExtraFunctionsModule) Functions(io.crate.metadata.Functions) OutputTimeUnit(org.openjdk.jmh.annotations.OutputTimeUnit) BiConsumer(java.util.function.BiConsumer) TearDown(org.openjdk.jmh.annotations.TearDown) Setup(org.openjdk.jmh.annotations.Setup) Mode(org.openjdk.jmh.annotations.Mode) AggregationFunction(io.crate.execution.engine.aggregation.AggregationFunction) HyperLogLogPlusPlus(io.crate.execution.engine.aggregation.impl.HyperLogLogPlusPlus) Signature(io.crate.metadata.functions.Signature) MurmurHash3(org.elasticsearch.common.hash.MurmurHash3) State(org.openjdk.jmh.annotations.State) RamAccounting(io.crate.breaker.RamAccounting) Collectors(java.util.stream.Collectors) InputCollectExpression(io.crate.execution.engine.collect.InputCollectExpression) Benchmark(org.openjdk.jmh.annotations.Benchmark) StandardCharsets(java.nio.charset.StandardCharsets) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) Version(org.elasticsearch.Version) Row(io.crate.data.Row) Literal(io.crate.expression.symbol.Literal) AggregateMode(io.crate.expression.symbol.AggregateMode) DataTypes(io.crate.types.DataTypes) AggregateCollector(io.crate.execution.engine.aggregation.AggregateCollector) Fork(org.openjdk.jmh.annotations.Fork) OnHeapMemoryManager(io.crate.memory.OnHeapMemoryManager) ModulesBuilder(org.elasticsearch.common.inject.ModulesBuilder) Collections(java.util.Collections) Row1(io.crate.data.Row1) OffHeapMemoryManager(io.crate.memory.OffHeapMemoryManager) OnHeapMemoryManager(io.crate.memory.OnHeapMemoryManager) Functions(io.crate.metadata.Functions) AggregateCollector(io.crate.execution.engine.aggregation.AggregateCollector) ExtraFunctionsModule(io.crate.module.ExtraFunctionsModule) AggregationFunction(io.crate.execution.engine.aggregation.AggregationFunction) Input(io.crate.data.Input) InputCollectExpression(io.crate.execution.engine.collect.InputCollectExpression) HyperLogLogPlusPlus(io.crate.execution.engine.aggregation.impl.HyperLogLogPlusPlus) ModulesBuilder(org.elasticsearch.common.inject.ModulesBuilder) MurmurHash3(org.elasticsearch.common.hash.MurmurHash3) Setup(org.openjdk.jmh.annotations.Setup)

Example 95 with Setup

use of org.openjdk.jmh.annotations.Setup in project crate by crate.

the class PreExecutionBenchmark method setup.

@Setup
public void setup() throws Exception {
    Path tempDir = Files.createTempDirectory("");
    Settings settings = Settings.builder().put("path.home", tempDir.toAbsolutePath().toString()).build();
    Environment environment = new Environment(settings, tempDir);
    node = new Node(environment, List.of(Netty4Plugin.class), true);
    node.start();
    Injector injector = node.injector();
    sqlOperations = injector.getInstance(SQLOperations.class);
    analyzer = injector.getInstance(Analyzer.class);
    planner = injector.getInstance(Planner.class);
    clusterService = injector.getInstance(ClusterService.class);
    nodeCtx = injector.getInstance(NodeContext.class);
    String statement = "create table users (id int primary key, name string, date timestamp, text string index using fulltext)";
    var resultReceiver = new BaseResultReceiver();
    sqlOperations.newSystemSession().quickExec(statement, resultReceiver, Row.EMPTY);
    resultReceiver.completionFuture().get(5, TimeUnit.SECONDS);
}
Also used : Path(java.nio.file.Path) NodeContext(io.crate.metadata.NodeContext) Node(org.elasticsearch.node.Node) ClusterService(org.elasticsearch.cluster.service.ClusterService) Injector(org.elasticsearch.common.inject.Injector) Environment(org.elasticsearch.env.Environment) BaseResultReceiver(io.crate.action.sql.BaseResultReceiver) Planner(io.crate.planner.Planner) SQLOperations(io.crate.action.sql.SQLOperations) Settings(org.elasticsearch.common.settings.Settings) Setup(org.openjdk.jmh.annotations.Setup)

Aggregations

Setup (org.openjdk.jmh.annotations.Setup)303 Random (java.util.Random)62 File (java.io.File)33 ArrayList (java.util.ArrayList)24 InputRow (io.druid.data.input.InputRow)15 BenchmarkDataGenerator (io.druid.benchmark.datagen.BenchmarkDataGenerator)14 HyperUniquesSerde (io.druid.query.aggregation.hyperloglog.HyperUniquesSerde)14 HyperUniquesSerde (org.apache.druid.query.aggregation.hyperloglog.HyperUniquesSerde)14 DataGenerator (org.apache.druid.segment.generator.DataGenerator)14 Scope (org.openjdk.jmh.annotations.Scope)14 State (org.openjdk.jmh.annotations.State)14 DataSegment (org.apache.druid.timeline.DataSegment)13 Benchmark (org.openjdk.jmh.annotations.Benchmark)13 ByteBuffer (java.nio.ByteBuffer)12 IOException (java.io.IOException)11 IndexSpec (io.druid.segment.IndexSpec)10 List (java.util.List)10 TopicPartition (org.apache.kafka.common.TopicPartition)10 TimeUnit (java.util.concurrent.TimeUnit)9 LinearShardSpec (org.apache.druid.timeline.partition.LinearShardSpec)9