Skip to content

Commit d0594a5

Browse files
committed
Enable concurrent_segment_search auto mode by default
Signed-off-by: Vikasht34 <viktari@amazon.com>
1 parent 3638c13 commit d0594a5

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
1111
### Dependencies
1212

1313
### Changed
14+
* Enable concurrent_segment_search auto mode by default[#17978](https://github.com/opensearch-project/OpenSearch/pull/17978)
1415

1516
### Deprecated
1617

server/src/main/java/org/opensearch/search/SearchService.java

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ public class SearchService extends AbstractLifecycleComponent implements IndexEv
279279

280280
public static final Setting<String> CLUSTER_CONCURRENT_SEGMENT_SEARCH_MODE = Setting.simpleString(
281281
"search.concurrent_segment_search.mode",
282-
CONCURRENT_SEGMENT_SEARCH_MODE_NONE,
282+
CONCURRENT_SEGMENT_SEARCH_MODE_AUTO,
283283
value -> {
284284
switch (value) {
285285
case CONCURRENT_SEGMENT_SEARCH_MODE_ALL:
@@ -303,12 +303,11 @@ public class SearchService extends AbstractLifecycleComponent implements IndexEv
303303
// value == 0 means lucene slice computation will be used
304304
public static final Setting<Integer> CONCURRENT_SEGMENT_SEARCH_TARGET_MAX_SLICE_COUNT_SETTING = Setting.intSetting(
305305
CONCURRENT_SEGMENT_SEARCH_TARGET_MAX_SLICE_COUNT_KEY,
306-
CONCURRENT_SEGMENT_SEARCH_TARGET_MAX_SLICE_COUNT_DEFAULT_VALUE,
306+
computeDefaultSliceCount(),
307307
CONCURRENT_SEGMENT_SEARCH_TARGET_MAX_SLICE_COUNT_DEFAULT_VALUE,
308308
Property.Dynamic,
309309
Property.NodeScope
310310
);
311-
312311
// value 0 means rewrite filters optimization in aggregations will be disabled
313312
@ExperimentalApi
314313
public static final Setting<Integer> MAX_AGGREGATION_REWRITE_FILTERS = Setting.intSetting(
@@ -1871,6 +1870,27 @@ public MinAndMax<?> estimatedMinAndMax() {
18711870
}
18721871
}
18731872

1873+
/**
1874+
* Computes the default maximum number of slices for concurrent segment search.
1875+
* <p>
1876+
* This value is dynamically calculated as:
1877+
* <pre>
1878+
* min(availableProcessors / 2, 4)
1879+
* </pre>
1880+
* This ensures that:
1881+
* <ul>
1882+
* <li>On small machines, it avoids over-threading.</li>
1883+
* <li>On larger machines, it caps the concurrency to a reasonable level (4 slices).</li>
1884+
* </ul>
1885+
* This default is used when the user does not explicitly set the
1886+
* {@code search.concurrent.max_slice_count} cluster setting.
1887+
*
1888+
* @return the computed default slice count
1889+
*/
1890+
private static int computeDefaultSliceCount() {
1891+
return Math.min(Runtime.getRuntime().availableProcessors() / 2, 4);
1892+
}
1893+
18741894
/**
18751895
* This helper class ensures we only execute either the success or the failure path for {@link SearchOperationListener}.
18761896
* This is crucial for some implementations like {@link org.opensearch.index.search.stats.ShardSearchStats}.

0 commit comments

Comments
 (0)