Skip to content

Remove bound on SEARCH_COORDINATION default size #98264

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/reference/modules/threadpool.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ There are several thread pools, but the important ones include:

`search_coordination`::
For lightweight search-related coordination operations. Thread pool type is
`fixed` with a size of a max of `min(5, (`<<node.processors,
`# of allocated processors`>>`) / 2)`, and queue_size of `1000`.
`fixed` with a size of `(`<<node.processors, `# of allocated processors`>>`) / 2`,
and queue_size of `1000`.

`get`::
For get operations. Thread pool type is
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,11 @@ public ThreadPool(final Settings settings, final ExecutorBuilder<?>... customBui

final Map<String, ExecutorBuilder> builders = new HashMap<>();
final int allocatedProcessors = EsExecutors.allocatedProcessors(settings);
final int halfProc = halfAllocatedProcessors(allocatedProcessors);
final int halfProcMaxAt5 = halfAllocatedProcessorsMaxFive(allocatedProcessors);
final int halfProcMaxAt10 = halfAllocatedProcessorsMaxTen(allocatedProcessors);
final int genericThreadPoolMax = boundedBy(4 * allocatedProcessors, 128, 512);

builders.put(
Names.GENERIC,
new ScalingExecutorBuilder(Names.GENERIC, 4, genericThreadPoolMax, TimeValue.timeValueSeconds(30), false)
Expand Down Expand Up @@ -216,7 +218,7 @@ public ThreadPool(final Settings settings, final ExecutorBuilder<?>... customBui
);
builders.put(
Names.SEARCH_COORDINATION,
new FixedExecutorBuilder(settings, Names.SEARCH_COORDINATION, halfProcMaxAt5, 1000, TaskTrackingConfig.DEFAULT)
new FixedExecutorBuilder(settings, Names.SEARCH_COORDINATION, halfProc, 1000, TaskTrackingConfig.DEFAULT)
);
builders.put(
Names.AUTO_COMPLETE,
Expand Down Expand Up @@ -588,15 +590,20 @@ public ScheduledExecutorService scheduler() {
* than value, otherwise value
*/
static int boundedBy(int value, int min, int max) {
assert min < max : min + " vs " + max;
return Math.min(max, Math.max(min, value));
}

static int halfAllocatedProcessors(final int allocatedProcessors) {
return (allocatedProcessors + 1) / 2;
}

static int halfAllocatedProcessorsMaxFive(final int allocatedProcessors) {
return boundedBy((allocatedProcessors + 1) / 2, 1, 5);
return boundedBy(halfAllocatedProcessors(allocatedProcessors), 1, 5);
}

static int halfAllocatedProcessorsMaxTen(final int allocatedProcessors) {
return boundedBy((allocatedProcessors + 1) / 2, 1, 10);
return boundedBy(halfAllocatedProcessors(allocatedProcessors), 1, 10);
}

static int twiceAllocatedProcessors(final int allocatedProcessors) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,26 @@ public void testForceMergeThreadPoolSize() {
}
}

public void testSearchCoordinationThreadPoolSize() {
final int expectedSize = randomIntBetween(1, EsExecutors.allocatedProcessors(Settings.EMPTY) / 2);
final int allocatedProcessors = Math.min(
EsExecutors.allocatedProcessors(Settings.EMPTY),
expectedSize * 2 - (randomIntBetween(0, 1))
);
final ThreadPool threadPool = new TestThreadPool(
"test",
Settings.builder().put(EsExecutors.NODE_PROCESSORS_SETTING.getKey(), allocatedProcessors).build()
);
try {
ThreadPool.Info info = threadPool.info(ThreadPool.Names.SEARCH_COORDINATION);
assertThat(info.getThreadPoolType(), equalTo(ThreadPool.ThreadPoolType.FIXED));
assertThat(info.getMin(), equalTo(expectedSize));
assertThat(info.getMax(), equalTo(expectedSize));
} finally {
assertTrue(terminate(threadPool));
}
}

public void testGetMaxSnapshotCores() {
int allocatedProcessors = randomIntBetween(1, 16);
assertThat(
Expand Down