mirror of
https://mirror.suhoan.cn/https://github.com/EasyTier/EasyTier.git
synced 2025-12-14 13:47:24 +08:00
allow set multithread count (#1056)
This commit is contained in:
@@ -92,6 +92,9 @@ core_clap:
|
|||||||
multi_thread:
|
multi_thread:
|
||||||
en: "use multi-thread runtime, default is single-thread"
|
en: "use multi-thread runtime, default is single-thread"
|
||||||
zh-CN: "使用多线程运行时,默认为单线程"
|
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:
|
disable_ipv6:
|
||||||
en: "do not use ipv6"
|
en: "do not use ipv6"
|
||||||
zh-CN: "不使用IPv6"
|
zh-CN: "不使用IPv6"
|
||||||
@@ -178,6 +181,9 @@ core_clap:
|
|||||||
private_mode:
|
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."
|
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,则不允许使用了与本网络不相同的网络名称和密码的节点通过本节点进行握手或中转"
|
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:
|
core_app:
|
||||||
panic_backtrace_save:
|
panic_backtrace_save:
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ pub fn gen_default_flags() -> Flags {
|
|||||||
enable_quic_proxy: false,
|
enable_quic_proxy: false,
|
||||||
disable_quic_input: false,
|
disable_quic_input: false,
|
||||||
foreign_relay_bps_limit: u64::MAX,
|
foreign_relay_bps_limit: u64::MAX,
|
||||||
|
multi_thread_count: 2,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -276,6 +276,13 @@ struct NetworkOptions {
|
|||||||
)]
|
)]
|
||||||
multi_thread: Option<bool>,
|
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(
|
#[arg(
|
||||||
long,
|
long,
|
||||||
env = "ET_DISABLE_IPV6",
|
env = "ET_DISABLE_IPV6",
|
||||||
@@ -819,6 +826,7 @@ impl NetworkOptions {
|
|||||||
f.foreign_relay_bps_limit = self
|
f.foreign_relay_bps_limit = self
|
||||||
.foreign_relay_bps_limit
|
.foreign_relay_bps_limit
|
||||||
.unwrap_or(f.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);
|
cfg.set_flags(f);
|
||||||
|
|
||||||
if !self.exit_nodes.is_empty() {
|
if !self.exit_nodes.is_empty() {
|
||||||
|
|||||||
@@ -256,8 +256,9 @@ impl EasyTierLauncher {
|
|||||||
|
|
||||||
self.thread_handle = Some(std::thread::spawn(move || {
|
self.thread_handle = Some(std::thread::spawn(move || {
|
||||||
let rt = if cfg.get_flags().multi_thread {
|
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()
|
tokio::runtime::Builder::new_multi_thread()
|
||||||
.worker_threads(2)
|
.worker_threads(worker_threads)
|
||||||
.enable_all()
|
.enable_all()
|
||||||
.build()
|
.build()
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -43,6 +43,8 @@ message FlagsInConfig {
|
|||||||
|
|
||||||
// a global relay limit, only work for foreign network
|
// a global relay limit, only work for foreign network
|
||||||
uint64 foreign_relay_bps_limit = 26;
|
uint64 foreign_relay_bps_limit = 26;
|
||||||
|
|
||||||
|
uint32 multi_thread_count = 27;
|
||||||
}
|
}
|
||||||
|
|
||||||
message RpcDescriptor {
|
message RpcDescriptor {
|
||||||
|
|||||||
Reference in New Issue
Block a user