[ https://issues.apache.org/jira/browse/HIVE-24723?focusedWorklogId=547138&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-547138 ]
ASF GitHub Bot logged work on HIVE-24723: ----------------------------------------- Author: ASF GitHub Bot Created on: 03/Feb/21 17:16 Start Date: 03/Feb/21 17:16 Worklog Time Spent: 10m Work Description: 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: us...@infra.apache.org Issue Time Tracking ------------------- Worklog Id: (was: 547138) Time Spent: 1h 10m (was: 1h) > Use ExecutorService in TezSessionPool > ------------------------------------- > > Key: HIVE-24723 > URL: https://issues.apache.org/jira/browse/HIVE-24723 > Project: Hive > Issue Type: Improvement > Components: Tez > Reporter: David Mollitor > Assignee: David Mollitor > Priority: Minor > Labels: pull-request-available > Time Spent: 1h 10m > Remaining Estimate: 0h > > Currently there are some wonky home-made thread pooling action going on in > {{TezSessionPool}}. Replace it with some JDK/Guava goodness. -- This message was sent by Atlassian Jira (v8.3.4#803005)