This is an automated email from the ASF dual-hosted git repository. houston pushed a commit to branch branch_9_8 in repository https://gitbox.apache.org/repos/asf/solr.git
commit 2e0304bc67c67cb28bb5675aee1c7a9f3c4c158a Author: Houston Putman <[email protected]> AuthorDate: Fri Feb 14 16:04:48 2025 -0600 SOLR-17673: Add back in option to use max CPU threads for searching (#3186) (cherry picked from commit cef521b1c232bdb27f63eaa1faed64c8f28cf14f) --- .../src/java/org/apache/solr/search/SolrIndexSearcher.java | 10 ++++++++-- solr/server/solr/solr.xml | 1 + .../configuration-guide/pages/configuring-solr-xml.adoc | 3 ++- .../modules/upgrade-notes/pages/major-changes-in-solr-9.adoc | 2 ++ 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java b/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java index d9d75444174..7d78297e6a9 100644 --- a/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java +++ b/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java @@ -147,6 +147,8 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable, SolrI private static final boolean useExitableDirectoryReader = Boolean.getBoolean("solr.useExitableDirectoryReader"); + public static final int EXECUTOR_MAX_CPU_THREADS = Runtime.getRuntime().availableProcessors(); + private final SolrCore core; private final IndexSchema schema; private final SolrDocumentFetcher docFetcher; @@ -223,9 +225,13 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable, SolrI * Shared across the whole node because it's a machine CPU resource. */ public static ExecutorService initCollectorExecutor(NodeConfig cfg) { - final int indexSearcherExecutorThreads = cfg.getIndexSearcherExecutorThreads(); - if (0 >= indexSearcherExecutorThreads) { + int indexSearcherExecutorThreads = cfg.getIndexSearcherExecutorThreads(); + if (indexSearcherExecutorThreads == 0) { return null; + } else if (indexSearcherExecutorThreads < 0) { + // Treat a negative value as "unlimited" and set it to the value number of available CPU + // threads + indexSearcherExecutorThreads = EXECUTOR_MAX_CPU_THREADS; } return new MDCAwareThreadPoolExecutor( diff --git a/solr/server/solr/solr.xml b/solr/server/solr/solr.xml index ac57111374a..963345095b3 100644 --- a/solr/server/solr/solr.xml +++ b/solr/server/solr/solr.xml @@ -34,6 +34,7 @@ <str name="allowPaths">${solr.allowPaths:}</str> <str name="allowUrls">${solr.allowUrls:}</str> <str name="hideStackTrace">${solr.hideStackTrace:false}</str> + <int name="indexSearcherExecutorThreads">${solr.searchThreads:0}</int> <solrcloud> diff --git a/solr/solr-ref-guide/modules/configuration-guide/pages/configuring-solr-xml.adoc b/solr/solr-ref-guide/modules/configuration-guide/pages/configuring-solr-xml.adoc index 85e11562135..a205dc7552f 100644 --- a/solr/solr-ref-guide/modules/configuration-guide/pages/configuring-solr-xml.adoc +++ b/solr/solr-ref-guide/modules/configuration-guide/pages/configuring-solr-xml.adoc @@ -185,10 +185,11 @@ The default value is equal to the number of processors. + [%autowidth,frame=none] |=== -|Optional |Default: number of available processors +|Optional |Default: 0 |=== + Specifies the number of threads that will be assigned for search queries. +A value of `-1` represents the total number of available processor threads available. `coreRootDirectory`:: + diff --git a/solr/solr-ref-guide/modules/upgrade-notes/pages/major-changes-in-solr-9.adoc b/solr/solr-ref-guide/modules/upgrade-notes/pages/major-changes-in-solr-9.adoc index 3216e0c04af..1fce467684f 100644 --- a/solr/solr-ref-guide/modules/upgrade-notes/pages/major-changes-in-solr-9.adoc +++ b/solr/solr-ref-guide/modules/upgrade-notes/pages/major-changes-in-solr-9.adoc @@ -72,6 +72,8 @@ Due to changes in Lucene 9, that isn't possible any more. In solrconfig.xml, the `indexSearcherExecutorThreads` now defaults to 0. Therefore, multi-threaded search execution is disabled at a node-level by default. It is currently recommended to only use an `indexSearcherExecutorThreads > 0` if all query requests sent to Solr opt-in to multiThreaded search. +Additionally, `indexSearcherExecutorThreads = -1` can be given to use the number of available CPU threads available to Solr. +This was the previous default. == Solr 9.8 === Configuration
