You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by GitBox <gi...@apache.org> on 2022/03/26 22:57:45 UTC
[GitHub] [lucene] javanna opened a new pull request #769: LUCENE-10486: Avoid unnecessary overhead in TopScoreDoc and TopField collector manager
javanna opened a new pull request #769:
URL: https://github.com/apache/lucene/pull/769
The createSharedManager static methods exposed by TopFieldCollector and TopScoreDocCollector rely unconditionally on a shared global counter as well as a shared max score accumulator. These can cause needless overhead when the search is not executed concurrently. This commit adds a new createManager method to both collectors that creates the proper hits threshold checker and max score accumulator depending on the provided arguments, specifically the total hits threshold and whether the search is multi-threaded or not. The searcher is considered multi-threaded when its leafSlices are set (meaning the executor was provided at contruction time) and there's more than one of them. Also, when totalHitsThreshold is Integer.MAX_VALUE a special hits threshold checker is used which does no counting, and no shared max score accumulator is used, regardless of whether the searcher is multi-threaded or not.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene] javanna commented on a change in pull request #769: LUCENE-10486: Avoid unnecessary overhead in TopScoreDoc and TopField collector manager
Posted by GitBox <gi...@apache.org>.
javanna commented on a change in pull request #769:
URL: https://github.com/apache/lucene/pull/769#discussion_r835822168
##########
File path: lucene/core/src/java/org/apache/lucene/search/TopFieldCollector.java
##########
@@ -481,26 +481,62 @@ static TopFieldCollector create(
}
}
+ /**
+ * Create a {@link CollectorManager} which uses a shared hit counter as well as a shared {@link
+ * MaxScoreAccumulator} when needed, depending on the provided leaf slices argument provided. When
+ * the searcher does not support concurrency, the returned manager will not incur the overhead of
+ * the shared data structures.
+ */
+ public static CollectorManager<TopFieldCollector, TopFieldDocs> createManager(
+ Sort sort, int numHits, FieldDoc after, int totalHitsThreshold, boolean multiThreaded) {
+ HitsThresholdChecker hitsThresholdChecker =
+ HitsThresholdChecker.create(totalHitsThreshold, multiThreaded);
+ return createManager(
+ sort,
+ numHits,
+ after,
+ hitsThresholdChecker,
+ MaxScoreAccumulator.createOrNull(totalHitsThreshold, multiThreaded));
+ }
+
/**
* Create a CollectorManager which uses a shared hit counter to maintain number of hits and a
- * shared {@link MaxScoreAccumulator} to propagate the minimum score accross segments if the
+ * shared {@link MaxScoreAccumulator} to propagate the minimum score across segments if the
* primary sort is by relevancy.
*/
public static CollectorManager<TopFieldCollector, TopFieldDocs> createSharedManager(
Review comment:
Is this method still useful or should it be deprecated in favour of the new one?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene] javanna commented on a change in pull request #769: LUCENE-10486: Avoid unnecessary overhead in TopScoreDoc and TopField collector manager
Posted by GitBox <gi...@apache.org>.
javanna commented on a change in pull request #769:
URL: https://github.com/apache/lucene/pull/769#discussion_r835822292
##########
File path: lucene/facet/src/java/org/apache/lucene/facet/DrillSideways.java
##########
@@ -198,23 +197,7 @@ public DrillSidewaysResult search(
final int fTopN = Math.min(topN, limit);
final CollectorManager<TopFieldCollector, TopFieldDocs> collectorManager =
- new CollectorManager<>() {
-
- @Override
- public TopFieldCollector newCollector() {
- return TopFieldCollector.create(sort, fTopN, after, Integer.MAX_VALUE);
- }
-
- @Override
- public TopFieldDocs reduce(Collection<TopFieldCollector> collectors) {
- final TopFieldDocs[] topFieldDocs = new TopFieldDocs[collectors.size()];
- int pos = 0;
- for (TopFieldCollector collector : collectors)
- topFieldDocs[pos++] = collector.topDocs();
- return TopDocs.merge(sort, topN, topFieldDocs);
- }
- };
-
+ TopFieldCollector.createSharedManager(sort, fTopN, after, Integer.MAX_VALUE);
Review comment:
here I was a bit on the fence: we ask for exact hits count, hence multi-threaded or not won't really make a difference. I found it confusing to provide the last argument knowing it would be ignored, so I called createSharedManager instead.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene] javanna commented on a change in pull request #769: LUCENE-10486: Avoid unnecessary overhead in TopScoreDoc and TopField collector manager
Posted by GitBox <gi...@apache.org>.
javanna commented on a change in pull request #769:
URL: https://github.com/apache/lucene/pull/769#discussion_r835821902
##########
File path: lucene/core/src/java/org/apache/lucene/search/TopDocsCollector.java
##########
@@ -29,6 +29,10 @@
*/
public abstract class TopDocsCollector<T extends ScoreDoc> implements Collector {
+ public static boolean isSearcherMultiThreaded(IndexSearcher searcher) {
Review comment:
I thought it was important to share the logic here instead of repeating it in multiple places, yet I was hesitant on adding a new public method to IndexSearcher, hence I ended up adding it here. I am open to other ideas.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org