You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by GitBox <gi...@apache.org> on 2020/11/17 18:15:41 UTC

[GitHub] [incubator-pinot] mayankshriv commented on a change in pull request #6225: Perf optimization for SQL GROUP BY ORDER BY

mayankshriv commented on a change in pull request #6225:
URL: https://github.com/apache/incubator-pinot/pull/6225#discussion_r525373552



##########
File path: pinot-common/src/main/java/org/apache/pinot/common/utils/CommonConstants.java
##########
@@ -173,6 +173,10 @@
     public static final int DEFAULT_MAX_REDUCE_THREADS_PER_QUERY =
         Math.max(1, Math.min(10, Runtime.getRuntime().availableProcessors() / 2)); // Same logic as CombineOperatorUtils
 
+    // used for SQL GROUP BY ORDER BY
+    public static final String CONFIG_OF_BROKER_SQL_GROUPBY_TRIM_THRESHOLD = "pinot.broker.sql.groupby.trim.threshold";

Review comment:
       Can we reuse existing PQL configs?

##########
File path: pinot-core/src/main/java/org/apache/pinot/core/data/table/ConcurrentIndexedTableOptimizedForLargeGroups.java
##########
@@ -0,0 +1,70 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 org.apache.pinot.core.data.table;
+
+import com.google.common.base.Preconditions;
+import org.apache.pinot.common.utils.DataSchema;
+import org.apache.pinot.core.query.request.context.QueryContext;
+
+
+public class ConcurrentIndexedTableOptimizedForLargeGroups extends ConcurrentIndexedTable {
+
+  public ConcurrentIndexedTableOptimizedForLargeGroups(DataSchema dataSchema,
+      QueryContext queryContext, int trimSize, int trimThreshold) {
+    super(dataSchema, queryContext, trimSize, trimThreshold);
+  }
+
+  @Override
+  public boolean upsert(Key key, Record newRecord) {
+    Preconditions.checkNotNull(key, "Cannot upsert record with null keys");

Review comment:
       Could be skipped for perf?

##########
File path: pinot-core/src/main/java/org/apache/pinot/core/query/reduce/GroupByDataTableReducer.java
##########
@@ -262,13 +264,24 @@ private IndexedTable getIndexedTable(DataSchema dataSchema, Collection<DataTable
     int numDataTables = dataTablesToReduce.size();
 
     // Get the number of threads to use for reducing.
-    int numReduceThreadsToUse = getNumReduceThreadsToUse(numDataTables, reducerContext.getMaxReduceThreadsPerQuery());
-
     // In case of single reduce thread, fall back to SimpleIndexedTable to avoid redundant locking/unlocking calls.
-    int capacity = GroupByUtils.getTableCapacity(_queryContext);
-    IndexedTable indexedTable =
-        (numReduceThreadsToUse > 1) ? new ConcurrentIndexedTable(dataSchema, _queryContext, capacity)
-            : new SimpleIndexedTable(dataSchema, _queryContext, capacity);
+    int numReduceThreadsToUse = getNumReduceThreadsToUse(numDataTables, reducerContext.getMaxReduceThreadsPerQuery());
+    int trimSize = GroupByUtils.getTableCapacity(_queryContext);
+    int trimThreshold = reducerContext.getSqlGroupByTrimThreshold();
+    IndexedTable indexedTable;
+    if (numReduceThreadsToUse <= 1) {
+      indexedTable = new SimpleIndexedTable(dataSchema, _queryContext, trimSize, trimThreshold);
+    } else {
+      if (trimThreshold == GroupByOrderByCombineOperator.INFINITE_INTER_SEGMENT_GROUPS_LIMIT) {

Review comment:
       Use `>=` instead of `==`?

##########
File path: pinot-core/src/main/java/org/apache/pinot/core/data/table/ConcurrentIndexedTableOptimizedForLargeGroups.java
##########
@@ -0,0 +1,70 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 org.apache.pinot.core.data.table;
+
+import com.google.common.base.Preconditions;
+import org.apache.pinot.common.utils.DataSchema;
+import org.apache.pinot.core.query.request.context.QueryContext;
+
+
+public class ConcurrentIndexedTableOptimizedForLargeGroups extends ConcurrentIndexedTable {

Review comment:
       Please add javadoc for the class and public methods.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org