Skip to content

Commit a82d835

Browse files
committed
allow to use snmalloc
1 parent b050fcb commit a82d835

23 files changed

Lines changed: 82 additions & 0 deletions

File tree

Cargo.lock

Lines changed: 25 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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ libc = "0.2.182"
191191
rustix = { version = "1.1", default-features = false }
192192
windows-sys = "0.61"
193193
socket2 = { version = "0.6.4", features = ["all"] }
194+
snmalloc = { package = "snmalloc-rs", version = "0.7", features = ["libc-api"] }
194195
#
195196
serde = "1.0"
196197
yaml-rust = { package = "yaml-rust2", version = "0.11" }

vey-bench/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ fastrand.workspace = true
4141
base64.workspace = true
4242
hickory-net.workspace = true
4343
hickory-proto.workspace = true
44+
snmalloc = { workspace = true, optional = true }
4445
vey-runtime.workspace = true
4546
vey-std-ext.workspace = true
4647
vey-types = { workspace = true, features = ["openssl", "rustls"] }
@@ -68,6 +69,8 @@ jemalloc = ["dep:vey-jemalloc"]
6869
mimalloc = ["dep:vey-mimalloc"]
6970
vendored-mimalloc = ["mimalloc", "vey-mimalloc?/vendored"]
7071
secure-vendored-mimalloc = ["mimalloc", "vey-mimalloc?/secure"]
72+
snmalloc = ["dep:snmalloc"]
73+
secure-snmalloc = ["snmalloc", "snmalloc/check"]
7174
quic = ["vey-types/quic", "vey-socks/quic", "vey-io-ext/quic", "vey-hickory-client/quic", "dep:quinn", "dep:h3", "dep:h3-quinn"]
7275
rustls-ring = ["vey-rustls-provider/rustls-ring", "vey-types/rustls-ring", "quinn?/rustls-ring"]
7376
rustls-aws-lc = ["vey-rustls-provider/rustls-aws-lc", "vey-types/rustls-aws-lc", "quinn?/rustls-aws-lc-rs"]

vey-bench/src/build.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ pub fn print_version() {
3535
}
3636
} else if #[cfg(feature = "mimalloc")] {
3737
println!("mimalloc {}", vey_mimalloc::lib_version());
38+
} else if #[cfg(feature = "snmalloc")] {
39+
println!("snmalloc");
3840
} else {
3941
println!("system");
4042
}

vey-bench/src/main.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ cfg_if::cfg_if! {
2222
} else if #[cfg(feature="mimalloc")] {
2323
#[global_allocator]
2424
static GLOBAL: vey_mimalloc::Mimalloc = vey_mimalloc::Mimalloc;
25+
} else if #[cfg(feature="snmalloc")] {
26+
#[global_allocator]
27+
static GLOBAL: snmalloc::SnMalloc = snmalloc::SnMalloc;
2528
}
2629
}
2730

vey-dcgen/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ openssl-sys.workspace = true # for openssl variant detection
1818
tokio = { workspace = true, features = ["macros", "net", "io-util", "time", "signal"] }
1919
kanal = { workspace = true, features = ["async"] }
2020
yaml-rust.workspace = true
21+
snmalloc = { workspace = true, optional = true }
2122
vey-std-ext.workspace = true
2223
vey-types.workspace = true
2324
vey-yaml = { workspace = true, features = ["histogram", "openssl"] }
@@ -39,6 +40,8 @@ jemalloc = ["dep:vey-jemalloc", "vey-daemon/jemalloc"]
3940
mimalloc = ["dep:vey-mimalloc", "vey-daemon/mimalloc"]
4041
vendored-mimalloc = ["mimalloc", "vey-mimalloc?/vendored"]
4142
secure-vendored-mimalloc = ["mimalloc", "vey-mimalloc?/secure"]
43+
snmalloc = ["dep:snmalloc"]
44+
secure-snmalloc = ["snmalloc", "snmalloc/check"]
4245
vendored-openssl = ["openssl/vendored"]
4346
vendored-tongsuo = ["openssl/tongsuo", "vey-cert-agent/tongsuo"]
4447
vendored-boringssl = ["openssl/boringssl"]

vey-dcgen/src/build.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ pub fn print_version(verbose_level: u8) {
3131
}
3232
} else if #[cfg(feature = "mimalloc")] {
3333
println!("mimalloc {}", vey_mimalloc::lib_version());
34+
} else if #[cfg(feature = "snmalloc")] {
35+
println!("snmalloc");
3436
} else {
3537
println!("system");
3638
}

vey-dcgen/src/main.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ cfg_if::cfg_if! {
1616
} else if #[cfg(feature="mimalloc")] {
1717
#[global_allocator]
1818
static GLOBAL: vey_mimalloc::Mimalloc = vey_mimalloc::Mimalloc;
19+
} else if #[cfg(feature="snmalloc")] {
20+
#[global_allocator]
21+
static GLOBAL: snmalloc::SnMalloc = snmalloc::SnMalloc;
1922
}
2023
}
2124

vey-gateway/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ uuid.workspace = true
4141
bitflags.workspace = true
4242
kanal = { workspace = true, features = ["async"] }
4343
rustc-hash.workspace = true
44+
snmalloc = { workspace = true, optional = true }
4445
vey-codec = { workspace = true, features = ["tls"] }
4546
vey-daemon = { workspace = true, features = ["event-log"] }
4647
vey-histogram.workspace = true
@@ -69,6 +70,8 @@ jemalloc = ["dep:vey-jemalloc", "vey-daemon/jemalloc"]
6970
mimalloc = ["dep:vey-mimalloc", "vey-daemon/mimalloc"]
7071
vendored-mimalloc = ["mimalloc", "vey-mimalloc?/vendored"]
7172
secure-vendored-mimalloc = ["mimalloc", "vey-mimalloc?/secure"]
73+
snmalloc = ["dep:snmalloc"]
74+
secure-snmalloc = ["snmalloc", "snmalloc/check"]
7275
ebpf = ["vey-daemon/ebpf"]
7376
vendored-libbpf = ["ebpf", "vey-reuseport/vendored-libbpf"]
7477
vendored-ebpf = ["ebpf", "vey-reuseport/vendored"]

vey-gateway/src/build.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ pub(crate) fn print_version(verbose_level: u8) {
3838
}
3939
} else if #[cfg(feature = "mimalloc")] {
4040
println!("mimalloc {}", vey_mimalloc::lib_version());
41+
} else if #[cfg(feature = "snmalloc")] {
42+
println!("snmalloc");
4143
} else {
4244
println!("system");
4345
}

0 commit comments

Comments
 (0)