Skip to content
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

Reduce the number of vert.x eventloops started by default #27025

Merged
merged 3 commits into from
Aug 19, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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.
cescoffier marked this conversation as resolved.
Show resolved Hide resolved
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