From 54a239d369ab44114fe224ecd00e432eb9609c17 Mon Sep 17 00:00:00 2001 From: Andrea Cavalli Date: Thu, 26 Sep 2024 23:57:18 +0200 Subject: [PATCH] Multi-core event loop group --- .../it/cavallium/rockserver/core/server/GrpcServer.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/it/cavallium/rockserver/core/server/GrpcServer.java b/src/main/java/it/cavallium/rockserver/core/server/GrpcServer.java index b1ca050..49a42be 100644 --- a/src/main/java/it/cavallium/rockserver/core/server/GrpcServer.java +++ b/src/main/java/it/cavallium/rockserver/core/server/GrpcServer.java @@ -15,6 +15,7 @@ import io.netty.channel.epoll.EpollEventLoopGroup; import io.netty.channel.epoll.EpollServerDomainSocketChannel; import io.netty.channel.nio.NioEventLoopGroup; import io.netty.channel.socket.nio.NioServerSocketChannel; +import io.netty.util.NettyRuntime; import it.cavallium.rockserver.core.client.RocksDBConnection; import it.cavallium.rockserver.core.common.*; import it.cavallium.rockserver.core.common.ColumnHashType; @@ -71,10 +72,11 @@ public class GrpcServer extends Server { EventLoopGroup elg; Class channelType; try { - elg = new EpollEventLoopGroup(Math.min(8, Runtime.getRuntime().availableProcessors())); + elg = new EpollEventLoopGroup(Runtime.getRuntime().availableProcessors() * 2); channelType = EpollServerDomainSocketChannel.class; } catch (UnsatisfiedLinkError ex) { - elg = new NioEventLoopGroup(); + LOG.warn("Can't load Epoll event loop group, the server will be slower", ex); + elg = new NioEventLoopGroup(Runtime.getRuntime().availableProcessors() * 2); channelType = NioServerSocketChannel.class; } this.elg = elg;