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

Configuration and tuning of the Vert.x instance used to power DevConsole #18965

Merged
merged 1 commit into from
Jul 23, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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