Skip to content

Commit

Permalink
SOLR-13350: multi-threaded search: replace cached with fixed threadpo…
Browse files Browse the repository at this point in the history
…ol (#2508)
  • Loading branch information
cpoerschke authored Jul 23, 2024
1 parent 06950c6 commit dfdbf85
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion solr/core/src/java/org/apache/solr/core/CoreContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ public CoreContainer(NodeConfig config, CoresLocator locator, boolean asyncSolrC
final int indexSearcherExecutorThreads = cfg.getIndexSearcherExecutorThreads();
if (0 < indexSearcherExecutorThreads) {
this.collectorExecutor =
ExecutorUtil.newMDCAwareCachedThreadPool(
ExecutorUtil.newMDCAwareFixedThreadPool(
indexSearcherExecutorThreads, // thread count
indexSearcherExecutorThreads * 1000, // queue size
new SolrNamedThreadFactory("searcherCollector"));
Expand Down
11 changes: 11 additions & 0 deletions solr/solrj/src/java/org/apache/solr/common/util/ExecutorUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,17 @@ public static ExecutorService newMDCAwareFixedThreadPool(
nThreads, nThreads, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(), threadFactory);
}

public static ExecutorService newMDCAwareFixedThreadPool(
int nThreads, int queueCapacity, ThreadFactory threadFactory) {
return new MDCAwareThreadPoolExecutor(
nThreads,
nThreads,
0L,
TimeUnit.MILLISECONDS,
new LinkedBlockingQueue<>(queueCapacity),
threadFactory);
}

/**
* See {@link java.util.concurrent.Executors#newSingleThreadExecutor(ThreadFactory)}. Note the
* thread is always active, even if no tasks are submitted to the executor.
Expand Down

0 comments on commit dfdbf85

Please sign in to comment.