Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SOLR-13350: Multithreaded search #2248

Closed
wants to merge 66 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
3cee3e5
SOLR-13350: Multithreaded search using CollectorManager
May 4, 2023
74c05e5
SOLR-13350: Fix tests and precommit
May 22, 2023
976f350
Merge remote-tracking branch 'origin/main' into jira/solr-13350
cpoerschke Feb 7, 2024
685cd7a
make it compile: ExecutorUtil.newMDCAwareCachedThreadPool signature c…
cpoerschke Feb 7, 2024
8732c33
Update CoreContainer.java - remove unused import
cpoerschke Feb 7, 2024
50160dc
Update CoreContainer.java - queue capacity to continue to match max t…
cpoerschke Feb 7, 2024
dbd2d8a
tentative: add indexSearcherExecutorThreads element to solr.xml
cpoerschke Feb 7, 2024
7b5e813
Merge remote-tracking branch 'origin/main' into jira/solr-13350
cpoerschke Feb 13, 2024
08d415f
git checkout origin/main -- solr/solr-ref-guide/modules/indexing-guide
cpoerschke Feb 13, 2024
3e66068
reduce SolrMultiCollectorManager.[Leaf]Collectors visibility
cpoerschke Feb 13, 2024
85b783e
Merge branch 'main' into jira/solr-13350
cpoerschke Feb 14, 2024
947d841
minor: SolrIndexSearcher style: add couple of finals
cpoerschke Feb 14, 2024
c69006a
factor out SolrIndexSearcher.allowMT(Query) utility; add SolrIndexSea…
cpoerschke Feb 14, 2024
366235b
minor: SolrIndexSearcher style: (post main merge) add back couple of …
cpoerschke Feb 14, 2024
1ec21d4
more logic in SolrIndexSearcher.allowMT utility for less code duplica…
cpoerschke Feb 14, 2024
a2b48a8
Merge remote-tracking branch 'origin/main' into jira/solr-13350
cpoerschke Feb 15, 2024
278a1ad
more 'needsScores' use (post origin/main merge conflict resolution)
cpoerschke Feb 15, 2024
2501f7b
tentative: in SolrIndexSearcher.searchCollectorManagers defer scoreMo…
cpoerschke Feb 16, 2024
cb3c1cb
undo TestDistributedSearch change by uncommenting commented out code
cpoerschke Feb 16, 2024
119db0f
Merge remote-tracking branch 'origin/main' into jira/solr-13350
cpoerschke Feb 16, 2024
2201a7d
factor out SolrIndexSearcher.populateScoresIfNeeded method
cpoerschke Feb 19, 2024
4a46b6d
use factored out SolrIndexSearcher.populateScoresIfNeeded method on n…
cpoerschke Feb 19, 2024
43be691
Merge branch 'main' into jira/solr-13350
cpoerschke Feb 20, 2024
65f9a4e
Merge remote-tracking branch 'origin/main' into jira/solr-13350
cpoerschke Feb 20, 2024
ab895b1
factor out SolrMultiCollectorManager.scoreMode method
cpoerschke Feb 21, 2024
a59fde7
reduce code duplication w.r.t. populateScoresIfNeeded and populateNex…
cpoerschke Feb 22, 2024
08088d1
Merge remote-tracking branch 'origin/main' into jira/solr-13350
cpoerschke Feb 22, 2024
5d9ba11
factor out SearchResult.getMaxScore method
cpoerschke Feb 22, 2024
21656ee
factor out SearchResult.getDocSet method
cpoerschke Feb 22, 2024
7219a1e
factor out SearchResult.getTopDocsResult method
cpoerschke Feb 22, 2024
0263958
mark SolrIndexSearcher.SearchResult.result Object[] private
cpoerschke Feb 22, 2024
34c7db0
tentative: replace ThreadSafeBitSet[Collector] with FixedBitSet[Colle…
cpoerschke Mar 1, 2024
cc04058
Merge remote-tracking branch 'origin/main' into jira/solr-13350
cpoerschke Mar 1, 2024
fd0d5ab
Revert "tentative: replace ThreadSafeBitSet[Collector] with FixedBitS…
cpoerschke Mar 1, 2024
00a06bc
Revert "Revert "tentative: replace ThreadSafeBitSet[Collector] with F…
cpoerschke Mar 4, 2024
186228d
dev increment: hide FixedBitSetCollector's bit set implementation
cpoerschke Mar 4, 2024
774d60c
Merge remote-tracking branch 'origin/main' into jira/solr-13350
cpoerschke Mar 4, 2024
14597f9
Merging main into branch
Apr 1, 2024
1dc4314
SOLR-13350: Using a RejectedExecutionHandler that submits the tasks b…
Apr 2, 2024
d51615e
Refactored MultiThreaded search into a separate class for better read…
noblepaul Apr 8, 2024
9af7c60
Refactored MultiThreaded search into a separate class for better read…
noblepaul Apr 8, 2024
30d6bf2
Merging main to branch
Apr 8, 2024
40a66e0
Merging main to branch
Apr 8, 2024
ff80c7e
Merge remote-tracking branch 'origin/main' into jira/solr-13350
cpoerschke Apr 8, 2024
bec277a
./gradlew tidy
cpoerschke Apr 8, 2024
842f580
Refactoring multithreaded searcher code into a separate class for bet…
Apr 8, 2024
bb80f0d
Removing spurious line
Apr 8, 2024
d8b371c
./gradlew tidy again
Apr 9, 2024
814b202
refactor
noblepaul Apr 9, 2024
3bb97a5
./gradlew tidy
cpoerschke Apr 11, 2024
e8d1efa
add back rawtypes for MultiThreadedSearcher
cpoerschke Apr 11, 2024
fdfef9f
(partially) explore segment level FixedBitSet use
cpoerschke Apr 12, 2024
493e284
Revert "(partially) explore segment level FixedBitSet use"
cpoerschke Apr 12, 2024
14b5742
Merge remote-tracking branch 'origin/main' into jira/solr-13350
cpoerschke Apr 12, 2024
b1ac976
basic segment level FixedBitSet use
cpoerschke Apr 15, 2024
e169916
Apply suggestions from code review
cpoerschke Apr 15, 2024
35d1383
./gradlew tidy
cpoerschke Apr 15, 2024
dd2a7ae
Merge remote-tracking branch 'origin/main' into jira/solr-13350
cpoerschke Apr 15, 2024
f7f96f1
SOLR-13350: Request parameter 'multithreaded' to disable/enable multi…
Apr 15, 2024
bdaf7d9
SOLR-13350: Request parameter 'multithreaded' to disable/enable multi…
Apr 15, 2024
07f0162
add multiThreaded parameter in QueryCommand
cpoerschke Apr 23, 2024
d14329d
Merge remote-tracking branch 'origin/main' into jira/solr-13350
cpoerschke Apr 23, 2024
a61b40e
Merging main into branch jira/solr-13350
May 6, 2024
b86ab72
Merge branch 'main' into jira/solr-13350
May 6, 2024
e7fb062
SOLR-13350: Defaulting to 4 threads for search
May 6, 2024
d8e9ef0
SOLR-13350: Defaulting to or 4 for number of threads
May 6, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion solr/CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ Other Changes
================== 9.7.0 ==================
New Features
---------------------
(No changes)
* SOLR-13350: Multithreaded search execution (Ishan Chattopadhyaya, Mark Miller, Christine Poerschke, David Smiley, noble)

Improvements
---------------------
Expand Down
3 changes: 3 additions & 0 deletions solr/bin/solr
Original file line number Diff line number Diff line change
Expand Up @@ -1441,6 +1441,9 @@ if [ $# -gt 0 ]; then
done
fi

# Setting number of threads for search
if ! command -v nproc &> /dev/null; then echo "Couldn't determine number of CPUs, using default number of search threads"; else cpus=`nproc`; SCRIPT_SOLR_OPTS+="-Dsolr.searchThreads=$cpus"; fi

# Default placement plugin
if [[ -n "${SOLR_PLACEMENTPLUGIN_DEFAULT:-}" ]] ; then
SCRIPT_SOLR_OPTS+=("-Dsolr.placementplugin.default=$SOLR_PLACEMENTPLUGIN_DEFAULT")
Expand Down
15 changes: 15 additions & 0 deletions solr/core/src/java/org/apache/solr/core/CoreContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.TimeoutException;
import java.util.function.Function;
Expand Down Expand Up @@ -175,6 +176,10 @@ public class CoreContainer {

final SolrCores solrCores;

public Executor getCollectorExecutor() {
return collectorExecutor;
}

public static class CoreLoadFailure {

public final CoreDescriptor cd;
Expand Down Expand Up @@ -278,6 +283,8 @@ public JerseyAppHandlerCache getJerseyAppHandlerCache() {

public final NodeRoles nodeRoles = new NodeRoles(System.getProperty(NodeRoles.NODE_ROLES_PROP));

private final ExecutorService collectorExecutor;

private final ClusterSingletons clusterSingletons =
new ClusterSingletons(
() ->
Expand Down Expand Up @@ -432,6 +439,12 @@ public CoreContainer(NodeConfig config, CoresLocator locator, boolean asyncSolrC
this.allowPaths = allowPathBuilder.build();

this.allowListUrlChecker = AllowListUrlChecker.create(config);

this.collectorExecutor =
ExecutorUtil.newMDCAwareCachedThreadPool(
cfg.getIndexSearcherExecutorThreads(), // thread count
cfg.getIndexSearcherExecutorThreads() * 1000, // queue size
new SolrNamedThreadFactory("searcherCollector"));
}

@SuppressWarnings({"unchecked"})
Expand Down Expand Up @@ -657,6 +670,7 @@ protected CoreContainer(Object testConstructor) {
distributedCollectionCommandRunner = Optional.empty();
allowPaths = null;
allowListUrlChecker = null;
collectorExecutor = null;
}

public static CoreContainer createAndLoad(Path solrHome) {
Expand Down Expand Up @@ -1248,6 +1262,7 @@ public void shutdown() {
}

ExecutorUtil.shutdownAndAwaitTermination(coreContainerAsyncTaskExecutor);
ExecutorUtil.shutdownAndAwaitTermination(collectorExecutor);
ExecutorService customThreadPool =
ExecutorUtil.newMDCAwareCachedThreadPool(new SolrNamedThreadFactory("closeThreadPool"));

Expand Down
18 changes: 18 additions & 0 deletions solr/core/src/java/org/apache/solr/core/NodeConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ public class NodeConfig {

private final int replayUpdatesThreads;

private final int indexSearcherExecutorThreads;

@Deprecated private final int transientCacheSize;

private final boolean useSchemaCache;
Expand Down Expand Up @@ -144,6 +146,7 @@ private NodeConfig(
CloudConfig cloudConfig,
Integer coreLoadThreads,
int replayUpdatesThreads,
int indexSearcherExecutorThreads,
int transientCacheSize,
boolean useSchemaCache,
String managementPath,
Expand Down Expand Up @@ -183,6 +186,7 @@ private NodeConfig(
this.cloudConfig = cloudConfig;
this.coreLoadThreads = coreLoadThreads;
this.replayUpdatesThreads = replayUpdatesThreads;
this.indexSearcherExecutorThreads = indexSearcherExecutorThreads;
this.transientCacheSize = transientCacheSize;
this.useSchemaCache = useSchemaCache;
this.managementPath = managementPath;
Expand Down Expand Up @@ -335,6 +339,10 @@ public int getReplayUpdatesThreads() {
return replayUpdatesThreads;
}

public int getIndexSearcherExecutorThreads() {
return indexSearcherExecutorThreads;
}

/**
* Returns a directory, optionally a comma separated list of directories that will be added to
* Solr's class path for searching for classes and plugins. The path is either absolute or
Expand Down Expand Up @@ -597,6 +605,7 @@ public static class NodeConfigBuilder {
private CloudConfig cloudConfig;
private int coreLoadThreads = DEFAULT_CORE_LOAD_THREADS;
private int replayUpdatesThreads = Runtime.getRuntime().availableProcessors();
private int indexSearcherExecutorThreads = DEFAULT_INDEX_SEARCHER_EXECUTOR_THREADS;
@Deprecated private int transientCacheSize = -1;
private boolean useSchemaCache = false;
private String managementPath;
Expand All @@ -618,6 +627,9 @@ public static class NodeConfigBuilder {
// No:of core load threads in cloud mode is set to a default of 8
public static final int DEFAULT_CORE_LOAD_THREADS_IN_CLOUD = 8;

public static final int DEFAULT_INDEX_SEARCHER_EXECUTOR_THREADS =
Copy link
Contributor

@noblepaul noblepaul Apr 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we set it as the as the no:of CPU cores ?

4;

private static final String DEFAULT_CORESLOCATORCLASS =
"org.apache.solr.core.CorePropertiesLocator";
private static final String DEFAULT_CORESORTERCLASS = "org.apache.solr.core.CoreSorter";
Expand Down Expand Up @@ -755,6 +767,11 @@ public NodeConfigBuilder setReplayUpdatesThreads(int replayUpdatesThreads) {
return this;
}

public NodeConfigBuilder setIndexSearcherExecutorThreads(int indexSearcherExecutorThreads) {
this.indexSearcherExecutorThreads = indexSearcherExecutorThreads;
return this;
}

// Remove in Solr 10.0

@Deprecated
Expand Down Expand Up @@ -904,6 +921,7 @@ public NodeConfig build() {
cloudConfig,
coreLoadThreads,
replayUpdatesThreads,
indexSearcherExecutorThreads,
transientCacheSize,
useSchemaCache,
managementPath,
Expand Down
3 changes: 3 additions & 0 deletions solr/core/src/java/org/apache/solr/core/SolrXmlConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,9 @@ private static NodeConfig fillSolrSection(NodeConfig.NodeConfigBuilder builder,
case "replayUpdatesThreads":
builder.setReplayUpdatesThreads(it.intVal(-1));
break;
case "indexSearcherExecutorThreads":
builder.setIndexSearcherExecutorThreads(it.intVal(-1));
break;
case "transientCacheSize":
log.warn("solr.xml transientCacheSize -- transient cores is deprecated");
builder.setTransientCacheSize(it.intVal(-1));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -372,10 +372,13 @@ public void process(ResponseBuilder rb) throws IOException {
return;
}

final boolean multiThreaded = params.getBool("multiThreaded", true);

// -1 as flag if not set.
long timeAllowed = params.getLong(CommonParams.TIME_ALLOWED, -1L);

QueryCommand cmd = rb.createQueryCommand();
cmd.setMultiThreaded(multiThreaded);
cmd.setTimeAllowed(timeAllowed);
cmd.setMinExactCount(getMinExactCount(params));
cmd.setDistribStatsDisabled(rb.isDistribStatsDisabled());
Expand Down
Loading
Loading