support snmalloc and rpmalloc

This commit is contained in:
zonyitoo
2021-05-07 10:55:43 +08:00
parent 13fc28d23c
commit 6c75ce19f4
4 changed files with 68 additions and 4 deletions

49
Cargo.lock generated
View File

@@ -205,6 +205,15 @@ dependencies = [
"vec_map",
]
[[package]]
name = "cmake"
version = "0.1.45"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eb6210b637171dfba4cda12e579ac6dc73f5165ad56133e5d72ef3131f320855"
dependencies = [
"cc",
]
[[package]]
name = "core-foundation"
version = "0.9.1"
@@ -1302,6 +1311,26 @@ dependencies = [
"winapi",
]
[[package]]
name = "rpmalloc"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8dae55d27fc56f399aec2583434bf22c7100fe983b2115bbc1d961ec4f7df5db"
dependencies = [
"rpmalloc-sys",
]
[[package]]
name = "rpmalloc-sys"
version = "0.2.1+1.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2a3e9198b851305d2f4bf86353b98016d79b871158ea5f9d0756b84022aefb99"
dependencies = [
"cc",
"libc",
"pkg-config",
]
[[package]]
name = "rustls"
version = "0.19.1"
@@ -1528,7 +1557,9 @@ dependencies = [
"log4rs",
"mimalloc",
"qrcode",
"rpmalloc",
"shadowsocks-service",
"snmalloc-rs",
"tcmalloc",
"tokio",
]
@@ -1604,6 +1635,24 @@ version = "1.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e"
[[package]]
name = "snmalloc-rs"
version = "0.2.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f5a6194d59b08fc87381e7c8a04ab4ab9967282b00f409bb742e08f3514ed0b"
dependencies = [
"snmalloc-sys",
]
[[package]]
name = "snmalloc-sys"
version = "0.2.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9518813a25ab2704a6df4968f609aa6949705409b6a854dcc87018d12961cbc8"
dependencies = [
"cmake",
]
[[package]]
name = "socket2"
version = "0.3.19"

View File

@@ -98,6 +98,9 @@ jemalloc = ["jemallocator"]
# Enable bundled tcmalloc
tcmalloc-vendored = ["tcmalloc/bundled"]
# Enable snmalloc for binaries
snmalloc = ["snmalloc-rs"]
# Enable tokio's multi-threaded runtime
multi-threaded = ["tokio/rt-multi-thread"]
@@ -125,6 +128,8 @@ tokio = { version = "1", features = ["rt", "signal"] }
mimalloc = { version = "0.1", optional = true }
tcmalloc = { version = "0.3", optional = true }
jemallocator = { version = "0.3", optional = true }
snmalloc-rs = { version = "0.2", optional = true }
rpmalloc = { version = "0.2", optional = true }
shadowsocks-service = { version = "1.10.6", path = "./crates/shadowsocks-service" }

View File

@@ -11,11 +11,11 @@ This is a port of [shadowsocks](https://github.com/shadowsocks/shadowsocks).
shadowsocks is a fast tunnel proxy that helps you bypass firewalls.
| Library | Description |
| ------- | ----------- |
| [**shadowsocks**](https://crates.io/crates/shadowsocks) | [![crates.io](https://img.shields.io/crates/v/shadowsocks.svg)](https://crates.io/crates/shadowsocks) [![docs.rs](https://img.shields.io/docsrs/shadowsocks)](https://docs.rs/shadowsocks) shadowsocks core protocol |
| Library | Description |
| ----------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [**shadowsocks**](https://crates.io/crates/shadowsocks) | [![crates.io](https://img.shields.io/crates/v/shadowsocks.svg)](https://crates.io/crates/shadowsocks) [![docs.rs](https://img.shields.io/docsrs/shadowsocks)](https://docs.rs/shadowsocks) shadowsocks core protocol |
| [**shadowsocks-service**](https://crates.io/crates/shadowsocks-service) | [![crates.io](https://img.shields.io/crates/v/shadowsocks-service.svg)](https://crates.io/crates/shadowsocks-service) [![docs.rs](https://img.shields.io/docsrs/shadowsocks-service)](https://docs.rs/shadowsocks-service) Services for serving shadowsocks |
| [**shadowsocks-rust**](https://crates.io/crates/shadowsocks-rust) | [![crates.io](https://img.shields.io/crates/v/shadowsocks-rust.svg)](https://crates.io/crates/shadowsocks-rust) Binaries running common shadowsocks services |
| [**shadowsocks-rust**](https://crates.io/crates/shadowsocks-rust) | [![crates.io](https://img.shields.io/crates/v/shadowsocks-rust.svg)](https://crates.io/crates/shadowsocks-rust) Binaries running common shadowsocks services |
## Build & Install
@@ -46,6 +46,8 @@ This project uses system (libc) memory allocator (Rust's default). But it also a
* `jemalloc` - Uses [jemalloc](http://jemalloc.net/) as global memory allocator
* `mimalloc` - Uses [mi-malloc](https://microsoft.github.io/mimalloc/) as global memory allocator
* `tcmalloc` - Uses [TCMalloc](https://google.github.io/tcmalloc/overview.html) as global memory allocator. It tries to link system-wide tcmalloc by default, use vendored from source with `tcmalloc-vendored`.
* `snmalloc` - Uses [snmalloc](https://github.com/microsoft/snmalloc) as gloal memory allocator
* `rpmalloc` - Uses [rpmalloc](https://github.com/mjansson/rpmalloc) as global memory allocator
### **crates.io**

View File

@@ -11,3 +11,11 @@ static ALLOC: tcmalloc::TCMalloc = tcmalloc::TCMalloc;
#[cfg(feature = "mimalloc")]
#[global_allocator]
static ALLOC: mimalloc::MiMalloc = mimalloc::MiMalloc;
#[cfg(feature = "snmalloc")]
#[global_allocator]
static ALLOC: snmalloc_rs::SnMalloc = snmalloc_rs::SnMalloc;
#[cfg(feature = "rpmalloc")]
#[global_allocator]
static ALLOC: rpmalloc::RpMalloc = rpmalloc::RpMalloc;