You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ja...@apache.org on 2023/06/15 09:35:16 UTC

[lucene] branch main updated: Increased the likelihood of leveraging inter-segment concurrency in tests (#12369)

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

javanna 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 bb6ec50d4c9 Increased the likelihood of leveraging inter-segment concurrency in tests (#12369)
bb6ec50d4c9 is described below

commit bb6ec50d4c96d1217a4426f8d0641bd520b25918
Author: Luca Cavanna <ja...@apache.org>
AuthorDate: Thu Jun 15 11:35:10 2023 +0200

    Increased the likelihood of leveraging inter-segment concurrency in tests (#12369)
    
    We have recently increased the likelihood of leveraging inter-segment search
    concurrency in tests when `newSearcher` is used to create the index
    searcher (see #959). When parallel execution is enabled though, it is
    dependent on the number of documents and segments. That means
    that out of 1000 test runs that use `RandomIndexWriter` to index a random
    number of docs up to 100, we will effectively parallelize only a couple
    of times.
    
    This commit increases the likelihood of running concurrent searches by
    randomly forcing 1 max segments per slice as well as 1 max doc per slice.
---
 .../java/org/apache/lucene/tests/util/LuceneTestCase.java    | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/lucene/test-framework/src/java/org/apache/lucene/tests/util/LuceneTestCase.java b/lucene/test-framework/src/java/org/apache/lucene/tests/util/LuceneTestCase.java
index 28830639a37..f5e72f87afb 100644
--- a/lucene/test-framework/src/java/org/apache/lucene/tests/util/LuceneTestCase.java
+++ b/lucene/test-framework/src/java/org/apache/lucene/tests/util/LuceneTestCase.java
@@ -17,7 +17,6 @@
 
 package org.apache.lucene.tests.util;
 
-import static com.carrotsearch.randomizedtesting.RandomizedTest.frequently;
 import static com.carrotsearch.randomizedtesting.RandomizedTest.randomBoolean;
 import static com.carrotsearch.randomizedtesting.RandomizedTest.systemPropertyAsBoolean;
 import static com.carrotsearch.randomizedtesting.RandomizedTest.systemPropertyAsInt;
@@ -1965,9 +1964,9 @@ public abstract class LuceneTestCase extends Assert {
             .addClosedListener(cacheKey -> TestUtil.shutdownExecutorService(ex));
       }
       IndexSearcher ret;
+      int maxDocPerSlice = random.nextBoolean() ? 1 : 1 + random.nextInt(1000);
+      int maxSegmentsPerSlice = random.nextBoolean() ? 1 : 1 + random.nextInt(10);
       if (wrapWithAssertions) {
-        int maxDocPerSlice = 1 + random.nextInt(1000);
-        int maxSegmentsPerSlice = 1 + random.nextInt(10);
         if (random.nextBoolean()) {
           ret =
               new AssertingIndexSearcher(random, r, ex) {
@@ -1985,9 +1984,7 @@ public abstract class LuceneTestCase extends Assert {
                 }
               };
         }
-      } else if (frequently()) {
-        int maxDocPerSlice = 1 + random.nextInt(1000);
-        int maxSegmentsPerSlice = 1 + random.nextInt(10);
+      } else {
         ret =
             new IndexSearcher(r, ex) {
               @Override
@@ -1995,9 +1992,6 @@ public abstract class LuceneTestCase extends Assert {
                 return slices(leaves, maxDocPerSlice, maxSegmentsPerSlice);
               }
             };
-      } else {
-        ret =
-            random.nextBoolean() ? new IndexSearcher(r, ex) : new IndexSearcher(r.getContext(), ex);
       }
       ret.setSimilarity(classEnvRule.similarity);
       ret.setQueryCachingPolicy(MAYBE_CACHE_POLICY);