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

Use jemalloc on non-windows to reduce memory fragmentation #738

Closed
wants to merge 1 commit into from
Closed
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
7 changes: 6 additions & 1 deletion BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,12 @@ rust_binary(
"@crates//:tower",
"@crates//:tracing",
"@crates//:tracing-subscriber",
],
] + select({
"@platforms//os:windows": [],
"//conditions:default": [
"@crates//:tikv-jemallocator",
],
}),
)

genrule(
Expand Down
21 changes: 21 additions & 0 deletions Cargo.lock

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

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,6 @@ tonic = { version = "0.11.0", features = ["gzip", "tls"] }
tower = "0.4.13"
tracing = "0.1.40"
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }

[target.'cfg(not(target_env = "msvc"))'.dependencies]
tikv-jemallocator = "0.5.4"
7 changes: 7 additions & 0 deletions src/bin/nativelink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ use tower::util::ServiceExt;
use tracing::{error, warn};
use tracing_subscriber::filter::{EnvFilter, LevelFilter};

// We use jemalloc because our program is frequently long-lived and memory fragmentation
// happens often with memory store. Jemalloc nearly completely removes memory fragmentation
// issues.
#[cfg(not(target_env = "msvc"))]
#[global_allocator]
static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc;

/// Note: This must be kept in sync with the documentation in `PrometheusConfig::path`.
const DEFAULT_PROMETHEUS_METRICS_PATH: &str = "/metrics";

Expand Down
Loading