Skip to content

Commit 08388e0

Browse files
committed
Internal: reduce the size of the search thread pool.
Follow-up of #9135. We initially decreased the stack size because it would end up a lot of memory when there are many threads. But we also have some thread pools that may be oversized, in particular the search thread pool. This commit proposes to decrease the default search thread pool size from `3 * num_procs` to `3 * num_procs / 2 + 1`. This is large enough to be sure that we can use all the machine resources even with a search-only work load but not too large in order to not consume too much memory because of the stack size and thread locals.
1 parent e8a42c6 commit 08388e0

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/main/java/org/elasticsearch/cache/recycler/PageCacheRecycler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ private static int maximumSearchThreadPoolSize(ThreadPool threadPool, Settings s
5959
assert searchThreadPool != null;
6060
final int maxSize = searchThreadPool.getMax();
6161
if (maxSize <= 0) {
62-
// happens with cached thread pools, let's assume there are at most 3x ${number of processors} threads
63-
return 3 * EsExecutors.boundedNumberOfProcessors(settings);
62+
// happens with cached thread pools, let's assume there are at most 2x ${number of processors} threads
63+
return 2 * EsExecutors.boundedNumberOfProcessors(settings);
6464
} else {
6565
return maxSize;
6666
}

src/main/java/org/elasticsearch/threadpool/ThreadPool.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public ThreadPool(Settings settings, @Nullable NodeSettingsService nodeSettingsS
113113
.put(Names.INDEX, settingsBuilder().put("type", "fixed").put("size", availableProcessors).put("queue_size", 200).build())
114114
.put(Names.BULK, settingsBuilder().put("type", "fixed").put("size", availableProcessors).put("queue_size", 50).build())
115115
.put(Names.GET, settingsBuilder().put("type", "fixed").put("size", availableProcessors).put("queue_size", 1000).build())
116-
.put(Names.SEARCH, settingsBuilder().put("type", "fixed").put("size", availableProcessors * 3).put("queue_size", 1000).build())
116+
.put(Names.SEARCH, settingsBuilder().put("type", "fixed").put("size", ((availableProcessors * 3) / 2) + 1).put("queue_size", 1000).build())
117117
.put(Names.SUGGEST, settingsBuilder().put("type", "fixed").put("size", availableProcessors).put("queue_size", 1000).build())
118118
.put(Names.PERCOLATE, settingsBuilder().put("type", "fixed").put("size", availableProcessors).put("queue_size", 1000).build())
119119
.put(Names.MANAGEMENT, settingsBuilder().put("type", "scaling").put("keep_alive", "5m").put("size", 5).build())

0 commit comments

Comments
 (0)