1
0
Fork 1
mirror of https://gitlab.com/mangadex-pub/mangadex_at_home.git synced 2024-01-19 02:48:37 +00:00

Made Netty thread count global instead of per-cpu

This commit is contained in:
Amos Ng 2020-06-12 20:05:45 +08:00
parent 4109ccd0b1
commit 662ceb44e4
No known key found for this signature in database
GPG key ID: 89086414F634D123
3 changed files with 9 additions and 9 deletions

View file

@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
- [2020-06-12] Raised ApacheClient socket limit to `2**18` by [@lflare].
- [2020-06-12] Changed gradle versioning to using `git describe` by [@lflare].
- [2020-06-12] Made Netty thread count global instead of per-cpu by [@lflare].
### Deprecated

View file

@ -16,17 +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;
@SerializedName("threads")
private final int threads;
public ClientSettings(long maxCacheSizeMib, long maxBandwidthMibPerHour, long maxBurstRateKibPerSecond,
int clientPort, String clientSecret, int threadsPerCpu) {
int clientPort, String clientSecret, int threads) {
this.maxCacheSizeMib = maxCacheSizeMib;
this.maxBandwidthMibPerHour = maxBandwidthMibPerHour;
this.maxBurstRateKibPerSecond = maxBurstRateKibPerSecond;
this.clientPort = clientPort;
this.clientSecret = Objects.requireNonNull(clientSecret);
this.threadsPerCpu = threadsPerCpu;
this.threads = threads;
}
public long getMaxCacheSizeMib() {
@ -49,15 +49,15 @@ public final class ClientSettings {
return clientSecret;
}
public int getThreadsPerCpu() {
return (threadsPerCpu > 0) ? threadsPerCpu : 16;
public int getThreads() {
return (threads > 0) ? threads : 16;
}
@Override
public String toString() {
return "ClientSettings{" + "maxCacheSizeMib=" + maxCacheSizeMib + ", maxBandwidthMibPerHour="
+ maxBandwidthMibPerHour + ", maxBurstRateKibPerSecond=" + maxBurstRateKibPerSecond + ", clientPort="
+ clientPort + ", clientSecret='" + "<hidden>" + '\'' + ", threadsPerCpu=" + getThreadsPerCpu() + '}';
+ clientPort + ", clientSecret='" + "<hidden>" + '\'' + ", threads=" + getThreads() + '}';
}
public static boolean isSecretValid(String clientSecret) {

View file

@ -37,8 +37,7 @@ import javax.net.ssl.SSLException
private val LOGGER = LoggerFactory.getLogger("Application")
class Netty(private val tls: ServerSettings.TlsCert, private val clientSettings: ClientSettings, private val stats: AtomicReference<Statistics>) : ServerConfig {
private val threadsToAllocate: Int
get() = Runtime.getRuntime().availableProcessors() * clientSettings.threadsPerCpu
private val threadsToAllocate = clientSettings.getThreads()
override fun toServer(httpHandler: HttpHandler): Http4kServer = object : Http4kServer {
private val masterGroup = NioEventLoopGroup(threadsToAllocate)