Search in sources :

Example 6 with OperationsPerInvocation

use of org.openjdk.jmh.annotations.OperationsPerInvocation in project presto by prestodb.

the class BenchmarkGroupByHash method groupByHashPreCompute.

@Benchmark
@OperationsPerInvocation(POSITIONS)
public Object groupByHashPreCompute(BenchmarkData data) {
    GroupByHash groupByHash = new MultiChannelGroupByHash(data.getTypes(), data.getChannels(), data.getHashChannel(), EXPECTED_SIZE, false, JOIN_COMPILER);
    data.getPages().forEach(groupByHash::getGroupIds);
    ImmutableList.Builder<Page> pages = ImmutableList.builder();
    PageBuilder pageBuilder = new PageBuilder(groupByHash.getTypes());
    for (int groupId = 0; groupId < groupByHash.getGroupCount(); groupId++) {
        pageBuilder.declarePosition();
        groupByHash.appendValuesTo(groupId, pageBuilder, 0);
        if (pageBuilder.isFull()) {
            pages.add(pageBuilder.build());
            pageBuilder.reset();
        }
    }
    pages.add(pageBuilder.build());
    return pageBuilder.build();
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) Page(com.facebook.presto.spi.Page) PageBuilder(com.facebook.presto.spi.PageBuilder) Benchmark(org.openjdk.jmh.annotations.Benchmark) OperationsPerInvocation(org.openjdk.jmh.annotations.OperationsPerInvocation)

Example 7 with OperationsPerInvocation

use of org.openjdk.jmh.annotations.OperationsPerInvocation in project presto by prestodb.

the class BenchmarkGroupByHash method baseline.

@Benchmark
@OperationsPerInvocation(POSITIONS)
public long baseline(BaselinePagesData data) {
    int hashSize = arraySize(GROUP_COUNT, 0.9f);
    int mask = hashSize - 1;
    long[] table = new long[hashSize];
    Arrays.fill(table, -1);
    long groupIds = 0;
    for (Page page : data.getPages()) {
        Block block = page.getBlock(0);
        int positionCount = block.getPositionCount();
        for (int position = 0; position < positionCount; position++) {
            long value = block.getLong(position, 0);
            int tablePosition = (int) (value & mask);
            while (table[tablePosition] != -1 && table[tablePosition] != value) {
                tablePosition++;
            }
            if (table[tablePosition] == -1) {
                table[tablePosition] = value;
                groupIds++;
            }
        }
    }
    return groupIds;
}
Also used : Block(com.facebook.presto.spi.block.Block) Page(com.facebook.presto.spi.Page) Benchmark(org.openjdk.jmh.annotations.Benchmark) OperationsPerInvocation(org.openjdk.jmh.annotations.OperationsPerInvocation)

Example 8 with OperationsPerInvocation

use of org.openjdk.jmh.annotations.OperationsPerInvocation in project presto by prestodb.

the class BenchmarkGroupByHash method baselineBigArray.

@Benchmark
@OperationsPerInvocation(POSITIONS)
public long baselineBigArray(BaselinePagesData data) {
    int hashSize = arraySize(GROUP_COUNT, 0.9f);
    int mask = hashSize - 1;
    LongBigArray table = new LongBigArray(-1);
    table.ensureCapacity(hashSize);
    long groupIds = 0;
    for (Page page : data.getPages()) {
        Block block = page.getBlock(0);
        int positionCount = block.getPositionCount();
        for (int position = 0; position < positionCount; position++) {
            long value = BIGINT.getLong(block, position);
            int tablePosition = (int) XxHash64.hash(value) & mask;
            while (table.get(tablePosition) != -1 && table.get(tablePosition) != value) {
                tablePosition++;
            }
            if (table.get(tablePosition) == -1) {
                table.set(tablePosition, value);
                groupIds++;
            }
        }
    }
    return groupIds;
}
Also used : LongBigArray(com.facebook.presto.array.LongBigArray) Block(com.facebook.presto.spi.block.Block) Page(com.facebook.presto.spi.Page) Benchmark(org.openjdk.jmh.annotations.Benchmark) OperationsPerInvocation(org.openjdk.jmh.annotations.OperationsPerInvocation)

Example 9 with OperationsPerInvocation

use of org.openjdk.jmh.annotations.OperationsPerInvocation in project presto by prestodb.

the class BenchmarkGroupByHash method addPagePreCompute.

@Benchmark
@OperationsPerInvocation(POSITIONS)
public Object addPagePreCompute(BenchmarkData data) {
    GroupByHash groupByHash = new MultiChannelGroupByHash(data.getTypes(), data.getChannels(), data.getHashChannel(), EXPECTED_SIZE, false, JOIN_COMPILER);
    data.getPages().forEach(groupByHash::addPage);
    ImmutableList.Builder<Page> pages = ImmutableList.builder();
    PageBuilder pageBuilder = new PageBuilder(groupByHash.getTypes());
    for (int groupId = 0; groupId < groupByHash.getGroupCount(); groupId++) {
        pageBuilder.declarePosition();
        groupByHash.appendValuesTo(groupId, pageBuilder, 0);
        if (pageBuilder.isFull()) {
            pages.add(pageBuilder.build());
            pageBuilder.reset();
        }
    }
    pages.add(pageBuilder.build());
    return pageBuilder.build();
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) Page(com.facebook.presto.spi.Page) PageBuilder(com.facebook.presto.spi.PageBuilder) Benchmark(org.openjdk.jmh.annotations.Benchmark) OperationsPerInvocation(org.openjdk.jmh.annotations.OperationsPerInvocation)

Aggregations

Benchmark (org.openjdk.jmh.annotations.Benchmark)9 OperationsPerInvocation (org.openjdk.jmh.annotations.OperationsPerInvocation)9 Page (com.facebook.presto.spi.Page)5 PageBuilder (com.facebook.presto.spi.PageBuilder)3 ImmutableList (com.google.common.collect.ImmutableList)3 InputRow (io.druid.data.input.InputRow)3 MapBasedInputRow (io.druid.data.input.MapBasedInputRow)3 BenchmarkMode (org.openjdk.jmh.annotations.BenchmarkMode)3 OutputTimeUnit (org.openjdk.jmh.annotations.OutputTimeUnit)3 Block (com.facebook.presto.spi.block.Block)2 LongBigArray (com.facebook.presto.array.LongBigArray)1 PrestoNode (com.facebook.presto.metadata.PrestoNode)1 Split (com.facebook.presto.metadata.Split)1 ConnectorSplit (com.facebook.presto.spi.ConnectorSplit)1 Node (com.facebook.presto.spi.Node)1 PlanNodeId (com.facebook.presto.sql.planner.plan.PlanNodeId)1 HashSet (java.util.HashSet)1