Skip to content

Commit

Permalink
Making force merge threadpool 1/8th of total cores (#17255) (#17353)
Browse files Browse the repository at this point in the history
(cherry picked from commit 38e4b33)

Signed-off-by: Gaurav Bafna <[email protected]>
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>
  • Loading branch information
1 parent 45ec72e commit 6698ccc
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Bump `reactor_netty` from 1.1.26 to 1.1.27 ([#17322](https://github.com/opensearch-project/OpenSearch/pull/17322))

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

### Deprecated

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,10 @@ public ThreadPool(
Names.FETCH_SHARD_STARTED,
new ScalingExecutorBuilder(Names.FETCH_SHARD_STARTED, 1, 2 * allocatedProcessors, TimeValue.timeValueMinutes(5))
);
builders.put(Names.FORCE_MERGE, new FixedExecutorBuilder(settings, Names.FORCE_MERGE, 1, -1));
builders.put(
Names.FORCE_MERGE,
new FixedExecutorBuilder(settings, Names.FORCE_MERGE, oneEighthAllocatedProcessors(allocatedProcessors), -1)
);
builders.put(
Names.FETCH_SHARD_STORE,
new ScalingExecutorBuilder(Names.FETCH_SHARD_STORE, 1, 2 * allocatedProcessors, TimeValue.timeValueMinutes(5))
Expand Down Expand Up @@ -692,6 +695,10 @@ static int boundedBy(int value, int min, int max) {
return Math.min(max, Math.max(min, value));
}

static int oneEighthAllocatedProcessors(final int allocatedProcessors) {
return boundedBy(allocatedProcessors / 8, 1, Integer.MAX_VALUE);
}

static int halfAllocatedProcessors(int allocatedProcessors) {
return (allocatedProcessors + 1) / 2;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,4 +196,12 @@ public void testThreadPoolResizeFail() {
terminate(threadPool);
}
}

public void testOneEighthAllocatedProcessors() {
assertThat(ThreadPool.oneEighthAllocatedProcessors(1), equalTo(1));
assertThat(ThreadPool.oneEighthAllocatedProcessors(4), equalTo(1));
assertThat(ThreadPool.oneEighthAllocatedProcessors(8), equalTo(1));
assertThat(ThreadPool.oneEighthAllocatedProcessors(32), equalTo(4));
assertThat(ThreadPool.oneEighthAllocatedProcessors(128), equalTo(16));
}
}

0 comments on commit 6698ccc

Please sign in to comment.