SOLR-17841: Use DocSetCollector for multithreaded DocSet(Faceted) search - #4724
Open
punAhuja wants to merge 1 commit into
Open
SOLR-17841: Use DocSetCollector for multithreaded DocSet(Faceted) search#4724punAhuja wants to merge 1 commit into
punAhuja wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
https://issues.apache.org/jira/browse/SOLR-17841
Description
Multithreaded(MT) search was slower than Singlethreaded(ST) search in the case of faceted queries. Faceted queries need a DocSet. ST already builds that with
DocSetCollector. MT used a customFixedBitSetCollectorinstead, and that made faceted search slower with MT on.This PR fixes that DocSet path so enabling MT no longer makes faceting worse.
Solution
Two changes in
MultiThreadedSearcher/SolrIndexSearcher:DocSetCollector, same as the single-threaded path. Each thread collects its own DocSet, then we OR them together. The oldFixedBitSetCollectorwas only used here, so I removed it.multiThreaded=truenow also needs a searcher thread pool. IfindexSearcherExecutorThreads=0, we used to take the multithreaded path anyway and it could get very slow. That case now falls back to single-threaded.I used an AI coding assistant (Cursor) while investigating and drafting the change. I reviewed the diff, ran the tests, and did the benchmarks myself.
Tests
Unit test:
TestMultiThreadedSearcher.testMultiThreadedDocSetMatchesSingleThreaded— same query,needDocSet=true, ST vs MT DocSets must match on a multi-segment index.Latency was measured with solr-bench (one client query at a time; searcher
pool
-Dsolr.searchThreads=-1). Suites, generator, NoMerge configset, andhow to run it:
https://github.com/SearchScale/solr-bench/tree/puneet/SOLR-17841-mt-search
I compared the same 1M-doc index merged vs forced to ~500 segments
(
NoMergePolicy, flush every 2000 docs). Queries areevent_timerange +event_typefilter, with and without facets.After the fix, facet MT is no longer worse on a normal index. With many
segments MT can win, especially on plain queries and p95.
NOTE: Still investigating whether MT can actually beat ST more broadly.
This PR only addresses the DocSet collector used for faceting. After the change, facet MT is no longer worse on a normal index, and with many segments MT can win (especially plain queries and p95).
Renato's findings on SOLR-17841 look like a separate bottleneck. Even with 50M docs force-merged to 5 segments, range queries were ~5× slower under MT; the profile pointed at
SolrRangeQuery/FixedBitSet.or, not this collector. I want to look at that next.Checklist
Please review the following and check all that apply:
mainbranch../gradlew check.