You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ab...@apache.org on 2024/10/01 02:13:44 UTC

(lucene) branch main updated: Speedup GlobalHitsThresholdChecker a little (#13836)

This is an automated email from the ASF dual-hosted git repository.

abr pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/lucene.git


The following commit(s) were added to refs/heads/main by this push:
     new 15168ce5c13 Speedup GlobalHitsThresholdChecker a little (#13836)
15168ce5c13 is described below

commit 15168ce5c13c8a17369dde498dda7490468fa191
Author: Armin Braun <me...@obrown.io>
AuthorDate: Tue Oct 1 04:13:36 2024 +0200

    Speedup GlobalHitsThresholdChecker a little (#13836)
    
    Even though this field is not `volatile`, writing it isn't free and
    causes needless cache thrashing at some frequency. We can speed things
    up by only writing the `true` value and never the `false` value.
---
 .../src/java/org/apache/lucene/search/HitsThresholdChecker.java     | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/lucene/core/src/java/org/apache/lucene/search/HitsThresholdChecker.java b/lucene/core/src/java/org/apache/lucene/search/HitsThresholdChecker.java
index 43ff4fecdbb..78e1a589a77 100644
--- a/lucene/core/src/java/org/apache/lucene/search/HitsThresholdChecker.java
+++ b/lucene/core/src/java/org/apache/lucene/search/HitsThresholdChecker.java
@@ -46,7 +46,11 @@ abstract class HitsThresholdChecker {
       if (thresholdReached) {
         return true;
       }
-      return thresholdReached = globalHitCount.longValue() > getHitsThreshold();
+      if (globalHitCount.longValue() > getHitsThreshold()) {
+        thresholdReached = true;
+        return true;
+      }
+      return false;
     }
 
     @Override