This is an automated email from the ASF dual-hosted git repository.
houston pushed a commit to branch branch_9x
in repository https://gitbox.apache.org/repos/asf/solr.git
The following commit(s) were added to refs/heads/branch_9x by this push:
new f20e880a923 SOLR-17673: Add back in option to use max CPU threads for
searching (#3186)
f20e880a923 is described below
commit f20e880a9232c42721d619ad06a41e05356a7a87
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 cd004406ef3..9172fbce7c7 100644
--- a/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java
+++ b/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java
@@ -148,6 +148,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;
@@ -224,9 +226,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;
}
// note that Lucene will catch a RejectedExecutionException to just run
the task.
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 05165cb63a2..7c0768c6b8c 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