Add time-to-first-result benchmark for groupBy (#10612)

This commit is contained in:
Jihoon Son 2020-12-01 10:32:37 -08:00 committed by GitHub
parent 2560bf0a19
commit d47d6cf081
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 50 additions and 0 deletions

View File

@ -38,6 +38,8 @@ import org.apache.druid.java.util.common.concurrent.Execs;
import org.apache.druid.java.util.common.granularity.Granularities;
import org.apache.druid.java.util.common.granularity.Granularity;
import org.apache.druid.java.util.common.guava.Sequence;
import org.apache.druid.java.util.common.guava.Yielder;
import org.apache.druid.java.util.common.guava.Yielders;
import org.apache.druid.java.util.common.logger.Logger;
import org.apache.druid.math.expr.ExprMacroTable;
import org.apache.druid.offheap.OffheapBufferGenerator;
@ -682,6 +684,28 @@ public class GroupByBenchmark
blackhole.consume(results);
}
/**
* Measure the time to produce the first ResultRow unlike {@link #queryMultiQueryableIndexX} measures total query
* processing time. This measure is useful since the Broker can start merging as soon as the first result is returned.
*/
@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
public void queryMultiQueryableIndexTTFR(Blackhole blackhole) throws IOException
{
QueryToolChest<ResultRow, GroupByQuery> toolChest = factory.getToolchest();
QueryRunner<ResultRow> theRunner = new FinalizeResultsQueryRunner<>(
toolChest.mergeResults(
factory.mergeRunners(executorService, makeMultiRunners())
),
(QueryToolChest) toolChest
);
Sequence<ResultRow> queryResult = theRunner.run(QueryPlus.wrap(query), ResponseContext.createEmpty());
Yielder<ResultRow> yielder = Yielders.each(queryResult);
yielder.close();
}
@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
@ -703,6 +727,32 @@ public class GroupByBenchmark
blackhole.consume(results);
}
/**
* Measure the time to produce the first ResultRow unlike {@link #queryMultiQueryableIndexWithSpilling} measures
* total query processing time. This measure is useful since the Broker can start merging as soon as the first
* result is returned.
*/
@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
public void queryMultiQueryableIndexWithSpillingTTFR(Blackhole blackhole) throws IOException
{
QueryToolChest<ResultRow, GroupByQuery> toolChest = factory.getToolchest();
QueryRunner<ResultRow> theRunner = new FinalizeResultsQueryRunner<>(
toolChest.mergeResults(
factory.mergeRunners(executorService, makeMultiRunners())
),
(QueryToolChest) toolChest
);
final GroupByQuery spillingQuery = query.withOverriddenContext(
ImmutableMap.of("bufferGrouperMaxSize", 4000)
);
Sequence<ResultRow> queryResult = theRunner.run(QueryPlus.wrap(spillingQuery), ResponseContext.createEmpty());
Yielder<ResultRow> yielder = Yielders.each(queryResult);
yielder.close();
}
@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MICROSECONDS)