Skip to content

Commit

Permalink
Merge pull request #27025 from Sanne/LowerIOThreads
Browse files Browse the repository at this point in the history
Reduce the number of vert.x eventloops started by default
  • Loading branch information
Sanne authored Aug 19, 2022
2 parents 84f2bca + 9bf91d3 commit 4d511de
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,7 @@ public static void startServerAfterFailedStart() {
doServerStart(vertx, buildConfig, config, LaunchMode.DEVELOPMENT, new Supplier<Integer>() {
@Override
public Integer get() {
return ProcessorInfo.availableProcessors()
* 2; //this is dev mode, so the number of IO threads not always being 100% correct does not really matter in this case
return ProcessorInfo.availableProcessors(); //this is dev mode, so the number of IO threads not always being 100% correct does not really matter in this case
}
}, null, false);
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,7 @@ public void testRequestReply() throws InterruptedException {
})
.await().atMost(Duration.ofSeconds(3));

if (Runtime.getRuntime().availableProcessors() > 1) {
assertEquals(3, MessageConsumers.MESSAGES.size());
} else {
assertTrue(MessageConsumers.MESSAGES.size() >= 2);
}
assertTrue(MessageConsumers.MESSAGES.size() >= 2);
}

@ApplicationScoped
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,10 @@ private static int calculateDefaultIOThreads() {
//it's hard to say what this number should be, but it is also obvious
//that for constrained environments we don't want a lot of event loops
//lets start with 10mb and adjust as needed
int recommended = ProcessorInfo.availableProcessors() * 2;
//We used to recommend a default of twice the number of cores,
//but more recent developments seem to suggest matching the number of cores 1:1
//being a more reasonable default. It also saves memory.
int recommended = ProcessorInfo.availableProcessors();
long mem = Runtime.getRuntime().maxMemory();
long memInMb = mem / (1024 * 1024);
long maxAllowed = memInMb / 10;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class VertxConfiguration {
public boolean classpathResolving;

/**
* The number of event loops. 2 x the number of core by default.
* The number of event loops. By default, it matches the number of CPUs detected on the system.
*/
@ConfigItem
public OptionalInt eventLoopsPoolSize;
Expand Down

0 comments on commit 4d511de

Please sign in to comment.