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

improve number of transport threads and max_timeout_heartbeat_count #103

Merged
merged 9 commits into from Sep 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -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
);
Expand Down Expand Up @@ -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 =
Expand Down
Expand Up @@ -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) {
Expand All @@ -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() {
Expand Down
Expand Up @@ -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() {
Expand Down