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

parity-util-mem: update mimalloc feature #352

Merged
merged 3 commits into from
Mar 13, 2020
Merged
Show file tree
Hide file tree
Changes from 2 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
11 changes: 3 additions & 8 deletions parity-util-mem/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,8 @@ dlmalloc = { version = "0.1.3", features = ["global"], optional = true }
wee_alloc = { version = "0.4.5", optional = true }
lru = { version = "0.4", optional = true }
hashbrown = { version = "0.6", optional = true }
# from https://github.com/microsoft/mimalloc:
# mimalloc can be built in secure mode,
# adding guard pages, randomized allocation, encrypted free lists, etc.
# to protect against various heap vulnerabilities.
# The performance penalty is only around 3% on average over our benchmarks.
mimallocator = { version = "0.1.3", features = ["secure"], optional = true }
mimalloc-sys = { version = "0.1.6", optional = true }
mimalloc = { version = "0.1.18", optional = true }
libmimalloc-sys = { version = "0.1.14", optional = true }
parity-util-mem-derive = { path = "derive", version = "0.1" }
impl-trait-for-tuples = "0.1.3"

Expand All @@ -45,7 +40,7 @@ weealloc-global = ["wee_alloc", "estimate-heapsize"]
# use jemalloc as global allocator
jemalloc-global = ["jemallocator"]
# use mimalloc as global allocator
mimalloc-global = ["mimallocator", "mimalloc-sys"]
mimalloc-global = ["mimalloc", "libmimalloc-sys"]
# implement additional types
ethereum-impls = ["ethereum-types", "primitive-types"]
# Full estimate: no call to allocator
Expand Down
2 changes: 1 addition & 1 deletion parity-util-mem/src/allocators.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ mod usable_size {
pub unsafe extern "C" fn malloc_usable_size(ptr: *const c_void) -> usize {
// mimalloc doesn't actually mutate the value ptr points to,
// but requires a mut pointer in the API
mimalloc_sys::mi_usable_size(ptr as *mut _)
libmimalloc_sys::mi_usable_size(ptr as *mut _)
}

} else if #[cfg(target_os = "linux")] {
Expand Down
10 changes: 5 additions & 5 deletions parity-util-mem/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,24 @@ cfg_if::cfg_if! {
not(target_os = "windows"),
not(target_arch = "wasm32")
))] {
#[global_allocator]
/// Global allocator
#[global_allocator]
pub static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;
} else if #[cfg(feature = "dlmalloc-global")] {
#[global_allocator]
/// Global allocator
#[global_allocator]
pub static ALLOC: dlmalloc::GlobalDlmalloc = dlmalloc::GlobalDlmalloc;
} else if #[cfg(feature = "weealloc-global")] {
#[global_allocator]
/// Global allocator
#[global_allocator]
pub static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;
} else if #[cfg(all(
feature = "mimalloc-global",
not(target_arch = "wasm32")
))] {
#[global_allocator]
/// Global allocator
pub static ALLOC: mimallocator::Mimalloc = mimallocator::Mimalloc;
#[global_allocator]
pub static ALLOC: mimalloc::MiMalloc = mimalloc::MiMalloc;
} else {
// default allocator used
}
Expand Down