You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@hive.apache.org by GitBox <gi...@apache.org> on 2021/02/03 17:16:28 UTC

[GitHub] [hive] belugabehr commented on a change in pull request #1939: HIVE-24723: Use ExecutorService in TezSessionPool

belugabehr commented on a change in pull request #1939:
URL: https://github.com/apache/hive/pull/1939#discussion_r569594294



##########
File path: ql/src/java/org/apache/hadoop/hive/ql/exec/tez/TezSessionPool.java
##########
@@ -395,20 +379,38 @@ int getInitialSize() {
     } while (!deltaRemaining.compareAndSet(oldVal, oldVal + delta));
     int toStart = oldVal + delta;
     if (toStart <= 0) return createDummyFuture();
-    LOG.info("Resizing the pool; adding " + toStart + " sessions");
-
-    // 2) If we need to create some extra sessions, we'd do it just like startup does.
-    int threadCount = Math.max(1, Math.min(toStart,
-        HiveConf.getIntVar(initConf, ConfVars.HIVE_SERVER2_TEZ_SESSION_MAX_INIT_THREADS)));
-    List<ListenableFutureTask<Boolean>> threadTasks = new ArrayList<>(threadCount);
-    // This is an async method, so always launch threads, even for a single task.
-    for (int i = 0; i < threadCount; ++i) {
-      ListenableFutureTask<Boolean> task = ListenableFutureTask.create(
-          new CreateSessionsRunnable(deltaRemaining));
-      new Thread(task, "Tez pool resize " + i).start();
-      threadTasks.add(task);
+    LOG.info("Resizing the pool; adding {} sessions", toStart);
+
+    final int threadCount =
+        Math.min(toStart, HiveConf.getIntVar(initConf, ConfVars.HIVE_SERVER2_TEZ_SESSION_MAX_INIT_THREADS));

Review comment:
       I would advise against that.  The first one initialized the pool, the second one is to increase the existing pool.  I think the naming is OK.

##########
File path: ql/src/java/org/apache/hadoop/hive/ql/exec/tez/TezSessionPool.java
##########
@@ -395,20 +379,38 @@ int getInitialSize() {
     } while (!deltaRemaining.compareAndSet(oldVal, oldVal + delta));
     int toStart = oldVal + delta;
     if (toStart <= 0) return createDummyFuture();
-    LOG.info("Resizing the pool; adding " + toStart + " sessions");
-
-    // 2) If we need to create some extra sessions, we'd do it just like startup does.
-    int threadCount = Math.max(1, Math.min(toStart,
-        HiveConf.getIntVar(initConf, ConfVars.HIVE_SERVER2_TEZ_SESSION_MAX_INIT_THREADS)));
-    List<ListenableFutureTask<Boolean>> threadTasks = new ArrayList<>(threadCount);
-    // This is an async method, so always launch threads, even for a single task.
-    for (int i = 0; i < threadCount; ++i) {
-      ListenableFutureTask<Boolean> task = ListenableFutureTask.create(
-          new CreateSessionsRunnable(deltaRemaining));
-      new Thread(task, "Tez pool resize " + i).start();
-      threadTasks.add(task);
+    LOG.info("Resizing the pool; adding {} sessions", toStart);
+
+    final int threadCount =
+        Math.min(toStart, HiveConf.getIntVar(initConf, ConfVars.HIVE_SERVER2_TEZ_SESSION_MAX_INIT_THREADS));
+
+    return createSessions(toStart, threadCount);
+  }
+
+  private ListenableFuture<List<Boolean>> createSessions(int sessionCount, int maxParallel) {

Review comment:
       Sure




----------------------------------------------------------------
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: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org