Skip to content

Commit edab23b

Browse files
committed
Enable jemalloc by feature. Enable parking_lot feature for tokio
ref: #174
1 parent d231c7f commit edab23b

File tree

7 files changed

+91
-1
lines changed

7 files changed

+91
-1
lines changed

Cargo.lock

Lines changed: 77 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ local-redir = []
8080
local-tunnel = []
8181
# Enable SOCKS4/4a protocol for sslocal
8282
local-socks4 = []
83+
# Enable jemalloc for binaries
84+
jemalloc = ["jemallocator"]
8385

8486
[dependencies]
8587
log = "0.4"
@@ -89,7 +91,7 @@ env_logger = { version = "0.7", default-features = false, features = ["termcolor
8991
chrono = "0.4"
9092
openssl = { version = "0.10", optional = true }
9193
libc = "^0.2.68"
92-
tokio = { version = "^0.2.11", features = ["macros", "net", "signal", "time", "sync", "process", "rt-threaded", "rt-core", "stream", "io-util"] }
94+
tokio = { version = "^0.2.11", features = ["macros", "net", "signal", "time", "sync", "process", "rt-threaded", "rt-core", "stream", "io-util", "parking_lot"] }
9395
tokio-native-tls = { version = "0.1", optional = true }
9496
native-tls = { version = "0.2", optional = true }
9597
tokio-rustls = { version = "0.13", optional = true }
@@ -136,6 +138,7 @@ iprange = "^0.6.3"
136138
ipnet = "2.2"
137139
async-trait = "0.1"
138140
lazy_static = "1.4"
141+
jemallocator = { version = "0.3", optional = true }
139142

140143
[target.'cfg(windows)'.dependencies]
141144
winapi = { version = "0.3", features = ["mswsock", "winsock2"] }

src/bin/allocator/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
//! Memory allocator
2+
3+
#[cfg(feature = "jemalloc")]
4+
#[global_allocator]
5+
static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;

src/bin/local.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ use shadowsocks::{
2626
ServerConfig,
2727
};
2828

29+
mod allocator;
2930
mod logging;
3031
mod monitor;
3132
mod validator;

src/bin/manager.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ use shadowsocks::{
2929
ServerAddr,
3030
};
3131

32+
mod allocator;
3233
mod logging;
3334
mod monitor;
3435
mod validator;

src/bin/server.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ use shadowsocks::{
3131
ServerConfig,
3232
};
3333

34+
mod allocator;
3435
mod logging;
3536
mod monitor;
3637
mod validator;

src/bin/ssurl.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ use qrcode::{types::Color, QrCode};
88

99
use shadowsocks::config::{Config, ConfigType, ServerConfig};
1010

11+
mod allocator;
12+
1113
const BLACK: &str = "\x1b[40m \x1b[0m";
1214
const WHITE: &str = "\x1b[47m \x1b[0m";
1315

0 commit comments

Comments
 (0)