Skip to content

Commit 38e4b33

Browse files
authored
Making force merge threadpool 1/8th of total cores (#17255)
Signed-off-by: Gaurav Bafna <gbbafna@amazon.com>
1 parent e34422b commit 38e4b33

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

CHANGELOG.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
2222
- Bump `reactor_netty` from 1.1.26 to 1.1.27 ([#17322](https://github.com/opensearch-project/OpenSearch/pull/17322))
2323

2424
### Changed
25-
- Convert transport-reactor-netty4 to use gradle version catalog [#17233](https://github.com/opensearch-project/OpenSearch/pull/17233))
25+
- Convert transport-reactor-netty4 to use gradle version catalog [#17233](https://github.com/opensearch-project/OpenSearch/pull/17233)
26+
- Increase force merge threads to 1/8th of cores [#17255](https://github.com/opensearch-project/OpenSearch/pull/17255)
2627

2728
### Deprecated
2829

server/src/main/java/org/opensearch/threadpool/ThreadPool.java

+8-1
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,10 @@ public ThreadPool(
278278
Names.FETCH_SHARD_STARTED,
279279
new ScalingExecutorBuilder(Names.FETCH_SHARD_STARTED, 1, 2 * allocatedProcessors, TimeValue.timeValueMinutes(5))
280280
);
281-
builders.put(Names.FORCE_MERGE, new FixedExecutorBuilder(settings, Names.FORCE_MERGE, 1, -1));
281+
builders.put(
282+
Names.FORCE_MERGE,
283+
new FixedExecutorBuilder(settings, Names.FORCE_MERGE, oneEighthAllocatedProcessors(allocatedProcessors), -1)
284+
);
282285
builders.put(
283286
Names.FETCH_SHARD_STORE,
284287
new ScalingExecutorBuilder(Names.FETCH_SHARD_STORE, 1, 2 * allocatedProcessors, TimeValue.timeValueMinutes(5))
@@ -678,6 +681,10 @@ static int boundedBy(int value, int min, int max) {
678681
return Math.min(max, Math.max(min, value));
679682
}
680683

684+
static int oneEighthAllocatedProcessors(final int allocatedProcessors) {
685+
return boundedBy(allocatedProcessors / 8, 1, Integer.MAX_VALUE);
686+
}
687+
681688
static int halfAllocatedProcessors(int allocatedProcessors) {
682689
return (allocatedProcessors + 1) / 2;
683690
}

server/src/test/java/org/opensearch/threadpool/ThreadPoolTests.java

+8
Original file line numberDiff line numberDiff line change
@@ -196,4 +196,12 @@ public void testThreadPoolResizeFail() {
196196
terminate(threadPool);
197197
}
198198
}
199+
200+
public void testOneEighthAllocatedProcessors() {
201+
assertThat(ThreadPool.oneEighthAllocatedProcessors(1), equalTo(1));
202+
assertThat(ThreadPool.oneEighthAllocatedProcessors(4), equalTo(1));
203+
assertThat(ThreadPool.oneEighthAllocatedProcessors(8), equalTo(1));
204+
assertThat(ThreadPool.oneEighthAllocatedProcessors(32), equalTo(4));
205+
assertThat(ThreadPool.oneEighthAllocatedProcessors(128), equalTo(16));
206+
}
199207
}

0 commit comments

Comments
 (0)