chore: enable jemalloc by default on unix (#3735)

This commit is contained in:
Alexey Shekhirin
2023-07-14 19:35:18 +01:00
committed by GitHub
parent d1610f3df9
commit c0cafc7a4f
4 changed files with 11 additions and 8 deletions

View File

@ -37,8 +37,6 @@ reth-basic-payload-builder = { path = "../../crates/payload/basic" }
reth-discv4 = { path = "../../crates/net/discv4" }
reth-metrics = { workspace = true }
reth-prune = { path = "../../crates/prune" }
jemallocator = { version = "0.5.0", optional = true }
jemalloc-ctl = { version = "0.5.0", optional = true }
# crypto
secp256k1 = { workspace = true, features = ["global-context", "rand-std", "recovery"] }
@ -88,7 +86,12 @@ pretty_assertions = "1.3.0"
humantime = "2.1.0"
const-str = "0.5.6"
[target.'cfg(not(windows))'.dependencies]
jemallocator = { version = "0.5.0", optional = true }
jemalloc-ctl = { version = "0.5.0", optional = true }
[features]
default = ["jemalloc"]
jemalloc = ["dep:jemallocator", "dep:jemalloc-ctl"]
jemalloc-prof = ["jemalloc", "jemallocator?/profiling"]
min-error-logs = ["tracing/release_max_level_error"]

View File

@ -40,5 +40,5 @@ pub mod test_vectors;
pub mod utils;
pub mod version;
#[cfg(feature = "jemalloc")]
#[cfg(all(feature = "jemalloc", unix))]
use jemallocator as _;

View File

@ -1,5 +1,5 @@
// We use jemalloc for performance reasons
#[cfg(feature = "jemalloc")]
#[cfg(all(feature = "jemalloc", unix))]
#[global_allocator]
static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;

View File

@ -121,7 +121,7 @@ pub(crate) async fn initialize(
Ok(())
}
#[cfg(feature = "jemalloc")]
#[cfg(all(feature = "jemalloc", unix))]
fn collect_memory_stats() {
use jemalloc_ctl::{epoch, stats};
use reth_metrics::metrics::gauge;
@ -169,7 +169,7 @@ fn collect_memory_stats() {
}
}
#[cfg(feature = "jemalloc")]
#[cfg(all(feature = "jemalloc", unix))]
fn describe_memory_stats() {
use reth_metrics::metrics::describe_gauge;
@ -206,8 +206,8 @@ fn describe_memory_stats() {
);
}
#[cfg(not(feature = "jemalloc"))]
#[cfg(not(all(feature = "jemalloc", unix)))]
fn collect_memory_stats() {}
#[cfg(not(feature = "jemalloc"))]
#[cfg(not(all(feature = "jemalloc", unix)))]
fn describe_memory_stats() {}