Skip to content

Commit

Permalink
Making force merge threadpool 1/8th of total cores
Browse files Browse the repository at this point in the history
Signed-off-by: Gaurav Bafna <[email protected]>
  • Loading branch information
gbbafna committed Feb 5, 2025
1 parent 865704b commit ffa411f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,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 @@ -678,6 +681,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 ffa411f

Please sign in to comment.