zhaih commented on code in PR #13124: URL: https://github.com/apache/lucene/pull/13124#discussion_r1503101967
########## lucene/core/src/java/org/apache/lucene/index/ConcurrentMergeScheduler.java: ########## @@ -910,4 +936,58 @@ public void setSuppressExceptions(ConcurrentMergeScheduler cms) { } }); } + + private class ScaledExecutor extends ThreadPoolExecutor { + + AtomicInteger activeCount = new AtomicInteger(0); + + public ScaledExecutor() { + super( + Math.max(0, maxThreadCount - 1), + Math.max(1, maxThreadCount - 1), + Long.MAX_VALUE, + TimeUnit.NANOSECONDS, + new SynchronousQueue<>()); + } + + private void updatePoolSize() { + int newMax = Math.max(0, maxThreadCount - 1); + if (newMax > getCorePoolSize()) { + setMaximumPoolSize(Math.max(newMax, 1)); + setCorePoolSize(newMax); + } else { + setCorePoolSize(newMax); + setMaximumPoolSize(Math.max(newMax, 1)); Review Comment: Aren't those two branch the same? -- 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. To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org