benwtrent commented on code in PR #13124: URL: https://github.com/apache/lucene/pull/13124#discussion_r1503892704
########## 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: The order of setting the max is important. But I am gonna change this. I think the core thread count should be `0` and we shouldn't update it at all and allow the threadpool to scale. -- 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