Skip to content

Commit

Permalink
Limit GroupByCombineOperator to use 2 * numCores threads instead of c…
Browse files Browse the repository at this point in the history
…reating one task per operator
  • Loading branch information
yashmayya committed Jan 20, 2025
1 parent d1ac83e commit e440a64
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import org.apache.pinot.core.query.aggregation.groupby.AggregationGroupByResult;
import org.apache.pinot.core.query.aggregation.groupby.GroupKeyGenerator;
import org.apache.pinot.core.query.request.context.QueryContext;
import org.apache.pinot.core.query.scheduler.resources.ResourceManager;
import org.apache.pinot.core.util.GroupByUtils;
import org.apache.pinot.spi.trace.Tracing;
import org.slf4j.Logger;
Expand All @@ -47,8 +48,6 @@

/**
* Combine operator for group-by queries.
* TODO: Use CombineOperatorUtils.getNumThreadsForQuery() to get the parallelism of the query instead of using
* all threads
*/
@SuppressWarnings("rawtypes")
public class GroupByCombineOperator extends BaseSingleBlockCombineOperator<GroupByResultsBlock> {
Expand Down Expand Up @@ -80,12 +79,13 @@ public GroupByCombineOperator(List<Operator> operators, QueryContext queryContex
}

/**
* For group-by queries, when maxExecutionThreads is not explicitly configured, create one task per operator.
* For group-by queries, when maxExecutionThreads is not explicitly configured, override it to create as many tasks
* as the default number of query worker threads (or the number of operators / segments if that's lower).
*/
private static QueryContext overrideMaxExecutionThreads(QueryContext queryContext, int numOperators) {
int maxExecutionThreads = queryContext.getMaxExecutionThreads();
if (maxExecutionThreads <= 0) {
queryContext.setMaxExecutionThreads(numOperators);
queryContext.setMaxExecutionThreads(Math.min(numOperators, ResourceManager.DEFAULT_QUERY_WORKER_THREADS));
}
return queryContext;
}
Expand Down

0 comments on commit e440a64

Please sign in to comment.