Skip to content
Permalink
Browse files
improve number of transport threads and max_timeout_heartbeat_count (#…
  • Loading branch information
coderzc committed Sep 26, 2021
1 parent 582f42c commit b7961283bae7e910e71d1da83d6c65b7e160c582
Showing 3 changed files with 17 additions and 12 deletions.
@@ -516,17 +516,15 @@ public static synchronized ComputerOptions instance() {
public static final ConfigOption<Integer> TRANSPORT_SERVER_THREADS =
new ConfigOption<>(
"transport.server_threads",
"The number of transport threads for server, the default " +
"value is CPUs.",
"The number of transport threads for server.",
positiveInt(),
TransportConf.NUMBER_CPU_CORES
);

public static final ConfigOption<Integer> TRANSPORT_CLIENT_THREADS =
new ConfigOption<>(
"transport.client_threads",
"The number of transport threads for client, the default " +
"value is CPUs.",
"The number of transport threads for client.",
positiveInt(),
TransportConf.NUMBER_CPU_CORES
);
@@ -718,7 +716,7 @@ public static synchronized ComputerOptions instance() {
"response continuously > max_heartbeat_timeouts the " +
"channel will be closed from client side.",
positiveInt(),
90
120
);

public static final ConfigOption<Long> HGKV_MAX_FILE_SIZE =
@@ -32,12 +32,11 @@
public class TransportConf {

public static final String SERVER_THREAD_GROUP_NAME =
"hugegraph-netty-server";
"transport-netty-server";
public static final String CLIENT_THREAD_GROUP_NAME =
"hugegraph-netty-client";
"transport-netty-client";
public static final int NUMBER_CPU_CORES =
Runtime.getRuntime().availableProcessors();

private final Config config;

public static TransportConf wrapConfig(Config config) {
@@ -63,13 +62,21 @@ public int serverPort() {
public int serverThreads() {
return Math.min(
this.config.get(ComputerOptions.TRANSPORT_SERVER_THREADS),
this.config.get(ComputerOptions.JOB_WORKERS_COUNT));
this.maxTransportThreads());
}

public int clientThreads() {
return Math.min(
this.config.get(ComputerOptions.TRANSPORT_CLIENT_THREADS),
this.config.get(ComputerOptions.JOB_WORKERS_COUNT));
this.maxTransportThreads());
}

private int maxTransportThreads() {
Integer workerCount = this.config
.get(ComputerOptions.JOB_WORKERS_COUNT);
Integer partitions = this.config
.get(ComputerOptions.JOB_PARTITIONS_COUNT);
return partitions / workerCount + 1;
}

public TransportProvider transportProvider() {
@@ -185,8 +185,8 @@ private NettyServerHandler newNettyServerHandler(MessageHandler handler) {

private IdleStateHandler newServerIdleStateHandler() {
long timeout = this.conf.serverIdleTimeout();
return new IdleStateHandler(DISABLE_IDLE_TIME, DISABLE_IDLE_TIME,
timeout, TimeUnit.MILLISECONDS);
return new IdleStateHandler(timeout, DISABLE_IDLE_TIME,
DISABLE_IDLE_TIME, TimeUnit.MILLISECONDS);
}

private IdleStateHandler newClientIdleStateHandler() {

0 comments on commit b796128

Please sign in to comment.