Skip to content

Commit 6698ccc

Browse files
Making force merge threadpool 1/8th of total cores (#17255) (#17353)
(cherry picked from commit 38e4b33) Signed-off-by: Gaurav Bafna <gbbafna@amazon.com> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent 45ec72e commit 6698ccc

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
@@ -16,7 +16,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
1616
- Bump `reactor_netty` from 1.1.26 to 1.1.27 ([#17322](https://github.com/opensearch-project/OpenSearch/pull/17322))
1717

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

2122
### Deprecated
2223

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

+8-1
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,10 @@ public ThreadPool(
289289
Names.FETCH_SHARD_STARTED,
290290
new ScalingExecutorBuilder(Names.FETCH_SHARD_STARTED, 1, 2 * allocatedProcessors, TimeValue.timeValueMinutes(5))
291291
);
292-
builders.put(Names.FORCE_MERGE, new FixedExecutorBuilder(settings, Names.FORCE_MERGE, 1, -1));
292+
builders.put(
293+
Names.FORCE_MERGE,
294+
new FixedExecutorBuilder(settings, Names.FORCE_MERGE, oneEighthAllocatedProcessors(allocatedProcessors), -1)
295+
);
293296
builders.put(
294297
Names.FETCH_SHARD_STORE,
295298
new ScalingExecutorBuilder(Names.FETCH_SHARD_STORE, 1, 2 * allocatedProcessors, TimeValue.timeValueMinutes(5))
@@ -692,6 +695,10 @@ static int boundedBy(int value, int min, int max) {
692695
return Math.min(max, Math.max(min, value));
693696
}
694697

698+
static int oneEighthAllocatedProcessors(final int allocatedProcessors) {
699+
return boundedBy(allocatedProcessors / 8, 1, Integer.MAX_VALUE);
700+
}
701+
695702
static int halfAllocatedProcessors(int allocatedProcessors) {
696703
return (allocatedProcessors + 1) / 2;
697704
}

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)