reth_cli_util/
allocator.rs
1cfg_if::cfg_if! {
9 if #[cfg(all(feature = "jemalloc", unix))] {
10 type AllocatorInner = tikv_jemallocator::Jemalloc;
11 } else if #[cfg(all(feature = "snmalloc", unix))] {
12 type AllocatorInner = snmalloc_rs::SnMalloc;
13 } else {
14 type AllocatorInner = std::alloc::System;
15 }
16}
17
18cfg_if::cfg_if! {
20 if #[cfg(all(feature = "snmalloc", feature = "jemalloc", unix))] {
21 use snmalloc_rs as _;
22 }
23}
24
25cfg_if::cfg_if! {
26 if #[cfg(feature = "tracy-allocator")] {
27 type AllocatorWrapper = tracy_client::ProfiledAllocator<AllocatorInner>;
28 tracy_client::register_demangler!();
29 const fn new_allocator_wrapper() -> AllocatorWrapper {
30 AllocatorWrapper::new(AllocatorInner {}, 100)
31 }
32 } else {
33 type AllocatorWrapper = AllocatorInner;
34 const fn new_allocator_wrapper() -> AllocatorWrapper {
35 AllocatorInner {}
36 }
37 }
38}
39
40pub type Allocator = AllocatorWrapper;
42
43pub const fn new_allocator() -> Allocator {
45 new_allocator_wrapper()
46}