Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
- name: Install build dependencies
run: |
sudo apt-get update
sudo apt-get install capnproto libjemalloc-dev libc-ares-dev libssl-dev liblua5.4-dev
sudo apt-get install capnproto libjemalloc-dev libmimalloc-dev libc-ares-dev libssl-dev liblua5.4-dev
- name: Install binutils
run: |
cargo install cargo-binutils@0.3.6
Expand Down Expand Up @@ -111,7 +111,7 @@ jobs:
- name: Install build dependencies
run: |
sudo apt-get update
sudo apt-get install capnproto libjemalloc-dev libssl-dev
sudo apt-get install capnproto libmimalloc-dev libssl-dev
- name: Install binutils
run: |
cargo install cargo-binutils@0.3.6
Expand Down Expand Up @@ -260,7 +260,7 @@ jobs:
- name: Install build dependencies
run: |
sudo apt-get update
sudo apt-get install capnproto libjemalloc-dev libc-ares-dev libssl-dev liblua5.4-dev
sudo apt-get install capnproto libmimalloc-dev libc-ares-dev libssl-dev liblua5.4-dev
- name: Install CA Certificates
run: |
sudo apt-get install ca-certificates
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/linux-basic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install capnproto libjemalloc-dev libc-ares-dev libssl-dev liblua5.4-dev
sudo apt-get install capnproto libjemalloc-dev libmimalloc-dev libc-ares-dev libssl-dev liblua5.4-dev
- name: Cargo build
run: cargo build --features jemalloc,lua54
- name: Cargo test
Expand All @@ -72,6 +72,6 @@ jobs:
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install capnproto libjemalloc-dev libc-ares-dev libssl-dev liblua5.4-dev
sudo apt-get install capnproto libjemalloc-dev libmimalloc-dev libc-ares-dev libssl-dev liblua5.4-dev
- name: Cargo clippy
run: cargo clippy --tests --workspace --features jemalloc,lua54 -- --deny warnings
2 changes: 1 addition & 1 deletion .github/workflows/macos-basic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
components: clippy
- name: Install dependencies
run: |
brew install capnp jemalloc openssl c-ares lua
brew install capnp jemalloc mimalloc openssl c-ares lua
- name: Cargo build
run: cargo build --features jemalloc,lua55
- name: Cargo clippy
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/windows-basic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ concurrency:
env:
CARGO_TERM_COLOR: always
VCPKG_ROOT: C:\vcpkg
WIN_FEATURES: rustls-ring,quic,c-ares,jemalloc
WIN_FEATURES: rustls-ring,quic,c-ares,mimalloc
AWS_LC_SYS_PREBUILT_NASM: 1

jobs:
Expand All @@ -48,7 +48,7 @@ jobs:
- name: Install tools (choco)
run: choco install capnproto
- name: Install lib dependencies (vcpkg)
run: vcpkg install --triplet=x64-windows-static-md openssl c-ares jemalloc
run: vcpkg install --triplet=x64-windows-static-md openssl c-ares jemalloc mimalloc
- name: Cargo build
run: cargo build --no-default-features --features $env:WIN_FEATURES
- name: Cargo clippy
Expand Down
60 changes: 46 additions & 14 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ members = [
"lib/vey-journal",
"lib/vey-json",
"lib/vey-macros",
"lib/vey-mimalloc",
"lib/vey-msgpack",
"lib/vey-openssl",
"lib/vey-redis-client",
Expand Down Expand Up @@ -227,6 +228,7 @@ vey-jemalloc = { version = "0.1", path = "lib/vey-jemalloc" }
vey-journal = { version = "0.4", path = "lib/vey-journal" }
vey-json = { version = "0.5", path = "lib/vey-json" }
vey-macros = { version = "0.1", path = "lib/vey-macros" }
vey-mimalloc = { version = "0.1", path = "lib/vey-mimalloc" }
vey-msgpack = { version = "0.4", path = "lib/vey-msgpack" }
vey-openssl = { version = "0.4", path = "lib/vey-openssl" }
vey-redis-client = { version = "0.3", path = "lib/vey-redis-client" }
Expand Down
2 changes: 1 addition & 1 deletion lib/vey-jemalloc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ edition.workspace = true
rust-version.workspace = true

[dependencies]
jemalloc-sys = { package = "libjemalloc-sys", version = "0.1" }
jemalloc-sys = { package = "vey-jemalloc-sys", version = "0.1" }
9 changes: 9 additions & 0 deletions lib/vey-mimalloc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[package]
name = "vey-mimalloc"
version = "0.1.0"
license.workspace = true
edition.workspace = true
rust-version.workspace = true

[dependencies]
mimalloc-sys = { package = "vey-mimalloc-sys", version = "0.1" }
29 changes: 29 additions & 0 deletions lib/vey-mimalloc/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* SPDX-License-Identifier: Apache-2.0
* SPDX-FileCopyrightText: 2026 VEY-OSS Developers.
*/

use core::alloc::{GlobalAlloc, Layout};

mod version;
pub use version::lib_version;

pub struct Mimalloc;

unsafe impl GlobalAlloc for Mimalloc {
unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
unsafe { mimalloc_sys::mi_aligned_alloc(layout.align(), layout.size()) as _ }
}

unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) {
unsafe { mimalloc_sys::mi_free_size_aligned(ptr as _, layout.size(), layout.align()) as _ }
}

unsafe fn alloc_zeroed(&self, layout: Layout) -> *mut u8 {
unsafe { mimalloc_sys::mi_zalloc_aligned(layout.size(), layout.align()) as _ }
}

unsafe fn realloc(&self, ptr: *mut u8, layout: Layout, new_size: usize) -> *mut u8 {
unsafe { mimalloc_sys::mi_realloc_aligned(ptr as _, new_size, layout.align()) as _ }
}
}
8 changes: 8 additions & 0 deletions lib/vey-mimalloc/src/version.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
* SPDX-License-Identifier: Apache-2.0
* SPDX-FileCopyrightText: 2026 VEY-OSS Developers.
*/

pub fn lib_version() -> i32 {
unsafe { mimalloc_sys::mi_version() }
}
2 changes: 1 addition & 1 deletion scripts/coverage/vey-bench.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ TEST_NAME="bench-ci"
. "${SCRIPTS_DIR}/enter.sh"

# build
cargo build --features jemalloc -p vey-bench -p vey-mkcert -p vey-proxy -p vey-proxy-ctl -p vey-statsd
cargo build --features mimalloc -p vey-bench -p vey-mkcert -p vey-proxy -p vey-proxy-ctl -p vey-statsd

all_binaries=$(find target/debug/ -maxdepth 1 -type f -perm /111 | awk '{print "-object "$0}')
all_objects=$(find target/debug/deps/ -type f -perm /111 -not -name "*.so" | awk '{print "-object "$0}')
Expand Down
2 changes: 1 addition & 1 deletion scripts/coverage/vey-keyless.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ TEST_NAME="vey-keyless-ci"
. "${SCRIPTS_DIR}/enter.sh"

# build
cargo build --features jemalloc,openssl-async-job -p vey-keyless -p vey-keyless-ctl -p vey-mkcert -p vey-statsd -p vey-bench
cargo build --features mimalloc,openssl-async-job -p vey-keyless -p vey-keyless-ctl -p vey-mkcert -p vey-statsd -p vey-bench

all_binaries=$(find target/debug/ -maxdepth 1 -type f -perm /111 | awk '{print "-object "$0}')
all_objects=$(find target/debug/deps/ -type f -perm /111 -not -name "*.so" | awk '{print "-object "$0}')
Expand Down
3 changes: 3 additions & 0 deletions vey-bench/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ description = "Multi-Target Benchmark Tool developed by the VEY project"
[dependencies]
thiserror.workspace = true
anyhow.workspace = true
cfg-if.workspace = true
clap.workspace = true
clap_complete.workspace = true
indicatif = "0.18"
Expand Down Expand Up @@ -56,13 +57,15 @@ vey-openssl.workspace = true
vey-hickory-client.workspace = true
vey-rustls-provider.workspace = true
vey-jemalloc = { workspace = true, optional = true }
vey-mimalloc = { workspace = true, optional = true }

[build-dependencies]
vey-build-env.workspace = true

[features]
default = ["quic", "rustls-ring"]
jemalloc = ["dep:vey-jemalloc"]
mimalloc = ["dep:vey-mimalloc"]
quic = ["vey-types/quic", "vey-socks/quic", "vey-io-ext/quic", "vey-hickory-client/quic", "dep:quinn", "dep:h3", "dep:h3-quinn"]
rustls-ring = ["vey-rustls-provider/rustls-ring", "vey-types/rustls-ring", "quinn?/rustls-ring"]
rustls-aws-lc = ["vey-rustls-provider/rustls-aws-lc", "vey-types/rustls-aws-lc", "quinn?/rustls-aws-lc-rs"]
Expand Down
16 changes: 12 additions & 4 deletions vey-bench/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,22 @@ const QUIC_FEATURE: Option<&str> = option_env!("VEY_QUIC_FEATURE");
pub fn print_version() {
println!("{PKG_NAME} {VERSION}");
print!("Features:");
#[cfg(feature = "jemalloc")]
if let Some(version) = vey_jemalloc::lib_version() {
print!(" jemalloc({})", version.to_string_lossy());
}
if let Some(quic) = QUIC_FEATURE {
print!(" {quic}");
}
println!();
print!("Memory Allocator: ");
cfg_if::cfg_if!(
if #[cfg(feature = "jemalloc")] {
if let Some(version) = vey_jemalloc::lib_version() {
println!("jemalloc {}", version.to_string_lossy());
}
} else if #[cfg(feature = "mimalloc")] {
println!("mimalloc {}", vey_mimalloc::lib_version());
} else {
println!("system");
}
);
if let Some(variant) = vey_openssl::variant_name() {
println!("OpenSSL Variant: {variant}");
}
Expand Down
Loading
Loading