reduce memory usage (#1133)

Large memory usage comes from:

Mimalloc hold large thread cache, causing abort 13M+ usage.
QUIC endpoint occupy 3M when GRO is enabled.
Smoltcp 64 tcp listener use 2MB.
This commit is contained in:
Sijie.Sun
2025-07-20 19:15:28 +08:00
committed by GitHub
parent 2660ed5fda
commit 876d550f68
11 changed files with 233 additions and 140 deletions
+14 -13
View File
@@ -8,7 +8,7 @@ edition = "2021"
authors = ["kkrainbow"]
keywords = ["vpn", "p2p", "network", "easytier"]
categories = ["network-programming", "command-line-utilities"]
rust-version = "1.84.0"
rust-version = "1.87.0"
license-file = "LICENSE"
readme = "README.md"
@@ -190,7 +190,7 @@ service-manager = { git = "https://github.com/chipsenkbeil/service-manager-rs.gi
zstd = { version = "0.13" }
kcp-sys = { git = "https://github.com/EasyTier/kcp-sys" }
kcp-sys = { git = "https://github.com/EasyTier/kcp-sys", rev = "0f0a0558391ba391c089806c23f369651f6c9eeb" }
prost-reflect = { version = "0.14.5", default-features = false, features = [
"derive",
@@ -213,14 +213,6 @@ humantime-serde = "1.1.1"
multimap = "0.10.0"
version-compare = "0.2.0"
jemallocator = { version = "0.5.4", optional = true }
jemalloc-ctl = { version = "0.5.4", optional = true }
jemalloc-sys = { version = "0.5.4", features = [
"stats",
"profiling",
"unprefixed_malloc_on_supported_platforms",
], optional = true }
[target.'cfg(any(target_os = "linux", target_os = "macos", target_os = "windows", target_os = "freebsd"))'.dependencies]
machine-uid = "0.5.3"
@@ -255,6 +247,15 @@ windows-sys = { version = "0.52", features = [
]}
winapi = { version = "0.3.9", features = ["impl-default"] }
[target.'cfg(not(windows))'.dependencies]
jemallocator = { package = "tikv-jemallocator", version = "0.6.0", optional = true }
jemalloc-ctl = { package = "tikv-jemalloc-ctl", version = "0.6.0", optional = true, features = [
] }
jemalloc-sys = { package = "tikv-jemalloc-sys", version = "0.6.0", features = [
"background_threads_runtime_support",
"background_threads",
], optional = true }
[build-dependencies]
tonic-build = "0.12"
globwalk = "0.8.1"
@@ -289,11 +290,10 @@ tokio-socks = "0.5.2"
[features]
default = ["wireguard", "mimalloc", "websocket", "smoltcp", "tun", "socks5", "quic"]
default = ["wireguard", "websocket", "smoltcp", "tun", "socks5", "quic"]
full = [
"websocket",
"wireguard",
"mimalloc",
"aes-gcm",
"smoltcp",
"tun",
@@ -313,4 +313,5 @@ websocket = [
]
smoltcp = ["dep:smoltcp", "dep:parking_lot"]
socks5 = ["dep:smoltcp"]
jemalloc = ["dep:jemallocator", "dep:jemalloc-ctl", "dep:jemalloc-sys"]
jemalloc = ["dep:jemallocator", "dep:jemalloc-sys"]
jemalloc-prof = ["jemalloc", "dep:jemalloc-ctl", "jemalloc-ctl/stats", "jemalloc-sys/profiling", "jemalloc-sys/stats"]