mcvsubbu commented on a change in pull request #3470: [PINOT-7328] Reduce lock 
contention in physical planning phase by reducing the total number of tasks
URL: https://github.com/apache/incubator-pinot/pull/3470#discussion_r234041287
 
 

 ##########
 File path: 
pinot-core/src/main/java/com/linkedin/pinot/core/plan/CombinePlanNode.java
 ##########
 @@ -78,15 +79,21 @@ public Operator run() {
       // Calculate the time out timestamp
       long endTime = System.currentTimeMillis() + 
TIME_OUT_IN_MILLISECONDS_FOR_PARALLEL_RUN;
 
+      int threads = Math.min(numPlanNodes/MIN_TASKS_PER_THREAD + 
((numPlanNodes % MIN_TASKS_PER_THREAD == 0) ? 0 : 1), // ceil without using 
double arithmetic
+          MAX_PLAN_THREADS);
+      int opsPerThread = Math.max(numPlanNodes/threads + ((numPlanNodes % 
threads == 0) ? 0 : 1), // ceil without using double arithmetic
+          MIN_TASKS_PER_THREAD);
       // Submit all jobs
-      Future[] futures = new Future[MAX_PLAN_TASKS];
-      for (int i = 0; i < MAX_PLAN_TASKS; i++) {
+      Future[] futures = new Future[threads];
+      for (int i = 0; i < threads; i++) {
         final int index = i;
         futures[i] = _executorService.submit(new 
TraceCallable<List<Operator>>() {
           @Override
           public List<Operator> callJob() throws Exception {
             List<Operator> operators = new ArrayList<>();
-            for(int count = index; count < numPlanNodes; count = count + 
MAX_PLAN_TASKS) {
+            int start = index * opsPerThread;
+            int limit = Math.min(opsPerThread, numPlanNodes - start);
+            for(int count = index * opsPerThread; count < start + limit; count 
= count + 1) {
 
 Review comment:
   ocd?
   can use 'start' instead of 'index * opsPerThread' ? 
   also, count++, maybe? 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to