Skip to content

Commit

Permalink
Merge pull request #18965 from Sanne/DevConsoleVertxTuning
Browse files Browse the repository at this point in the history
Configuration and tuning of the Vert.x instance used to power DevConsole
  • Loading branch information
Sanne authored Jul 23, 2021
2 parents c9e296c + dbf29e8 commit 9787d57
Showing 1 changed file with 36 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import java.util.Set;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
import java.util.concurrent.TimeUnit;
import java.util.function.Function;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -103,13 +104,18 @@
import io.quarkus.vertx.http.runtime.logstream.LogStreamRecorder;
import io.vertx.core.Handler;
import io.vertx.core.Vertx;
import io.vertx.core.VertxOptions;
import io.vertx.core.http.HttpMethod;
import io.vertx.core.http.HttpServerOptions;
import io.vertx.core.http.HttpServerRequest;
import io.vertx.core.http.impl.Http1xServerConnection;
import io.vertx.core.impl.EventLoopContext;
import io.vertx.core.impl.VertxBuilder;
import io.vertx.core.impl.VertxInternal;
import io.vertx.core.impl.VertxThread;
import io.vertx.core.net.impl.VertxHandler;
import io.vertx.core.net.impl.transport.Transport;
import io.vertx.core.spi.VertxThreadFactory;
import io.vertx.ext.web.Route;
import io.vertx.ext.web.Router;
import io.vertx.ext.web.RoutingContext;
Expand All @@ -134,7 +140,7 @@ public static void initializeVirtual() {
if (virtualBootstrap != null) {
return;
}
devConsoleVertx = Vertx.vertx();
devConsoleVertx = initializeDevConsoleVertx();
VertxInternal vertx = (VertxInternal) devConsoleVertx;
QuarkusClassLoader ccl = (QuarkusClassLoader) DevConsoleProcessor.class.getClassLoader();
ccl.addCloseTask(new Runnable() {
Expand Down Expand Up @@ -213,6 +219,35 @@ public void handle(HttpServerRequest event) {

}

/**
* Boots the Vert.x instance used by the DevConsole,
* applying some minimal tuning and customizations.
*
* @return the initialized Vert.x instance
*/
private static Vertx initializeDevConsoleVertx() {
final VertxOptions vertxOptions = new VertxOptions();
//Smaller than default, but larger than 1 to be on the safe side.
int POOL_SIZE = 2;
vertxOptions.setEventLoopPoolSize(POOL_SIZE);
vertxOptions.setWorkerPoolSize(POOL_SIZE);
vertxOptions.getMetricsOptions().setEnabled(false);
//Not good for development:
vertxOptions.getFileSystemOptions().setFileCachingEnabled(false);
VertxBuilder builder = new VertxBuilder(vertxOptions);
builder.threadFactory(new VertxThreadFactory() {
@Override
public VertxThread newVertxThread(Runnable target, String name, boolean worker, long maxExecTime,
TimeUnit maxExecTimeUnit) {
//Customize the Thread names so to not conflict with the names generated by the main Quarkus Vert.x instance
return new VertxThread(target, "[DevConsole]" + name, worker, maxExecTime, maxExecTimeUnit);
}
});
builder.transport(Transport.JDK);
builder.init();
return builder.vertx();
}

protected static void newRouter(Engine engine,
NonApplicationRootPathBuildItem nonApplicationRootPathBuildItem) {

Expand Down

0 comments on commit 9787d57

Please sign in to comment.