Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Support for selecting memory allocator #2255

Draft
wants to merge 3 commits into
base: develop
Choose a base branch
from
Draft
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
20 changes: 20 additions & 0 deletions nautilus_core/Cargo.lock

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

7 changes: 7 additions & 0 deletions nautilus_core/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ ustr = { workspace = true }
uuid = { workspace = true }
bincode = "1.3.3"
sysinfo = "0.33.1"
mimalloc = { version = "0.1", optional = true }

# Jemallocator does not work on aarch64 with musl
# [target.'cfg(all(target_family="unix", not(all(target_arch = "aarch64", target_env = "musl"))))'.dependencies]
# tikv-jemallocator = { version = "0.6", optional = true }

[dev-dependencies]
proptest = { workspace = true }
Expand All @@ -52,3 +57,5 @@ extension-module = [
ffi = ["cbindgen", "nautilus-core/ffi", "nautilus-model/ffi"]
"clock_v2" = []
python = ["pyo3", "nautilus-core/python", "nautilus-model/python"]
# allocator-jemalloc = ["tikv-jemallocator"]
allocator-mimalloc = ["mimalloc"]
23 changes: 23 additions & 0 deletions nautilus_core/common/src/allocator.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// #[cfg(all(feature = "allocator-jemalloc", feature = "allocator-mimalloc"))]
// compile_error!("Cannot enable both jemalloc and mimalloc allocators simultaneously");

#[cfg(feature = "allocator-mimalloc")]
#[global_allocator]
static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;

// #[cfg(all(
// feature = "allocator-jemalloc",
// any(target_os = "macos", target_os = "linux"),
// not(all(target_arch = "aarch64", target_env = "musl"))
// ))]
// #[global_allocator]
// static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc;

// // Jemallocator does not work on aarch64 with musl, fallback to system allocator
// #[cfg(all(
// feature = "allocator-jemalloc",
// target_arch = "aarch64",
// target_env = "musl",
// ))]
// #[global_allocator]
// static GLOBAL: std::alloc::System = std::alloc::System;
1 change: 1 addition & 0 deletions nautilus_core/common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#![allow(deprecated)]

pub mod actor;
pub mod allocator;
pub mod cache;
pub mod clock;
pub mod component;
Expand Down
Loading