mirror of
https://gitlab.com/mangadex-pub/mangadex_at_home.git
synced 2024-01-19 02:48:37 +00:00
Made threads-per-cpu configurable for moar speed
This commit is contained in:
parent
ac682e98c3
commit
40be05e4d4
|
@ -3,5 +3,6 @@
|
|||
"max_cache_size_mib": 2048,
|
||||
"client_port": 8080,
|
||||
"max_burst_rate_kib_per_second": 100,
|
||||
"max_bandwidth_mib_per_hour": 1
|
||||
"max_bandwidth_mib_per_hour": 1,
|
||||
"threads_per_cpu": 32
|
||||
}
|
||||
|
|
|
@ -16,14 +16,17 @@ public final class ClientSettings {
|
|||
private final int clientPort;
|
||||
@SerializedName("client_secret")
|
||||
private final String clientSecret;
|
||||
@SerializedName("threads_per_cpu")
|
||||
private final int threadsPerCPU;
|
||||
|
||||
public ClientSettings(long maxCacheSizeMib, long maxBandwidthMibPerHour, long maxBurstRateKibPerSecond,
|
||||
int clientPort, String clientSecret) {
|
||||
int clientPort, String clientSecret, int threadsPerCPU) {
|
||||
this.maxCacheSizeMib = maxCacheSizeMib;
|
||||
this.maxBandwidthMibPerHour = maxBandwidthMibPerHour;
|
||||
this.maxBurstRateKibPerSecond = maxBurstRateKibPerSecond;
|
||||
this.clientPort = clientPort;
|
||||
this.clientSecret = Objects.requireNonNull(clientSecret);
|
||||
this.threadsPerCPU = threadsPerCPU;
|
||||
}
|
||||
|
||||
public long getMaxCacheSizeMib() {
|
||||
|
@ -46,11 +49,15 @@ public final class ClientSettings {
|
|||
return clientSecret;
|
||||
}
|
||||
|
||||
public int getThreadsPerCPU() {
|
||||
return threadsPerCPU;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ClientSettings{" + "maxCacheSizeMib=" + maxCacheSizeMib + ", maxBandwidthMibPerHour="
|
||||
+ maxBandwidthMibPerHour + ", maxBurstRateKibPerSecond=" + maxBurstRateKibPerSecond + ", clientPort="
|
||||
+ clientPort + ", clientSecret='" + "<hidden>" + '\'' + '}';
|
||||
+ clientPort + ", clientSecret='" + "<hidden>" + '\'' + ", threadsPerCPU=" + threadsPerCPU + "}";
|
||||
}
|
||||
|
||||
public static boolean isSecretValid(String clientSecret) {
|
||||
|
|
|
@ -35,12 +35,12 @@ import java.util.concurrent.atomic.AtomicReference
|
|||
import javax.net.ssl.SSLException
|
||||
|
||||
private val LOGGER = LoggerFactory.getLogger("Application")
|
||||
private val THREADS_TO_ALLOCATE = Runtime.getRuntime().availableProcessors() * 32 / 2
|
||||
private val THREADS_TO_ALLOCATE = Runtime.getRuntime().availableProcessors()
|
||||
|
||||
class Netty(private val tls: ServerSettings.TlsCert, private val clientSettings: ClientSettings, private val stats: AtomicReference<Statistics>) : ServerConfig {
|
||||
override fun toServer(httpHandler: HttpHandler): Http4kServer = object : Http4kServer {
|
||||
private val masterGroup = NioEventLoopGroup(THREADS_TO_ALLOCATE)
|
||||
private val workerGroup = NioEventLoopGroup(THREADS_TO_ALLOCATE)
|
||||
private val masterGroup = NioEventLoopGroup(THREADS_TO_ALLOCATE * clientSettings.getThreadsPerCPU())
|
||||
private val workerGroup = NioEventLoopGroup(THREADS_TO_ALLOCATE * clientSettings.getThreadsPerCPU())
|
||||
private lateinit var closeFuture: ChannelFuture
|
||||
private lateinit var address: InetSocketAddress
|
||||
|
||||
|
@ -54,7 +54,7 @@ class Netty(private val tls: ServerSettings.TlsCert, private val clientSettings:
|
|||
|
||||
override fun start(): Http4kServer = apply {
|
||||
if (LOGGER.isInfoEnabled) {
|
||||
LOGGER.info("Starting webserver with {} threads", THREADS_TO_ALLOCATE)
|
||||
LOGGER.info("Starting webserver with {} threads", THREADS_TO_ALLOCATE * clientSettings.getThreadsPerCPU())
|
||||
}
|
||||
|
||||
val (mainCert, chainCert) = getX509Certs(tls.certificate)
|
||||
|
|
Loading…
Reference in a new issue