allow set multithread count (#1056)

This commit is contained in:
Sijie.Sun
2025-06-26 02:19:33 +08:00
committed by GitHub
parent cd26d9f669
commit 70e69a382e
5 changed files with 19 additions and 1 deletions

View File

@@ -92,6 +92,9 @@ core_clap:
multi_thread:
en: "use multi-thread runtime, default is single-thread"
zh-CN: "使用多线程运行时,默认为单线程"
multi_thread_count:
en: "the number of threads to use, default is 2, only effective when multi-thread is enabled, must be greater than 2"
zh-CN: "使用的线程数默认为2仅在多线程模式下有效。取值必须大于2"
disable_ipv6:
en: "do not use ipv6"
zh-CN: "不使用IPv6"
@@ -178,6 +181,9 @@ core_clap:
private_mode:
en: "if true, nodes with different network names or passwords from this network are not allowed to perform handshake or relay through this node."
zh-CN: "如果为true则不允许使用了与本网络不相同的网络名称和密码的节点通过本节点进行握手或中转"
foreign_relay_bps_limit:
en: "the maximum bps limit for foreign network relay, default is no limit. unit: BPS (bytes per second)"
zh-CN: "作为共享节点时,限制非本地网络的流量转发速率,默认无限制,单位 BPS (字节每秒)"
core_app:
panic_backtrace_save:

View File

@@ -43,6 +43,7 @@ pub fn gen_default_flags() -> Flags {
enable_quic_proxy: false,
disable_quic_input: false,
foreign_relay_bps_limit: u64::MAX,
multi_thread_count: 2,
}
}

View File

@@ -276,6 +276,13 @@ struct NetworkOptions {
)]
multi_thread: Option<bool>,
#[arg(
long,
env = "ET_MULTI_THREAD_COUNT",
help = t!("core_clap.multi_thread_count").to_string(),
)]
multi_thread_count: Option<u32>,
#[arg(
long,
env = "ET_DISABLE_IPV6",
@@ -819,6 +826,7 @@ impl NetworkOptions {
f.foreign_relay_bps_limit = self
.foreign_relay_bps_limit
.unwrap_or(f.foreign_relay_bps_limit);
f.multi_thread_count = self.multi_thread_count.unwrap_or(f.multi_thread_count);
cfg.set_flags(f);
if !self.exit_nodes.is_empty() {

View File

@@ -256,8 +256,9 @@ impl EasyTierLauncher {
self.thread_handle = Some(std::thread::spawn(move || {
let rt = if cfg.get_flags().multi_thread {
let worker_threads = 2.max(cfg.get_flags().multi_thread_count as usize);
tokio::runtime::Builder::new_multi_thread()
.worker_threads(2)
.worker_threads(worker_threads)
.enable_all()
.build()
} else {

View File

@@ -43,6 +43,8 @@ message FlagsInConfig {
// a global relay limit, only work for foreign network
uint64 foreign_relay_bps_limit = 26;
uint32 multi_thread_count = 27;
}
message RpcDescriptor {