Skip to content
Open
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
1 change: 1 addition & 0 deletions jemalloc-ctl/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ tikv-jemallocator = { path = "../jemallocator", version = "0.6.1" }
default = []
stats = ["tikv-jemalloc-sys/stats"]
profiling = ["tikv-jemalloc-sys/profiling"]
profiling_libunwind = ["tikv-jemalloc-sys/profiling_libunwind", "profiling"]
use_std = [ "libc/use_std" ]
disable_initial_exec_tls = ["tikv-jemalloc-sys/disable_initial_exec_tls"]

Expand Down
1 change: 1 addition & 0 deletions jemalloc-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ cc = "^1.0.13"
[features]
default = ["background_threads_runtime_support"]
profiling = []
profiling_libunwind = ["profiling"]
debug = []
background_threads_runtime_support = []
background_threads = [ "background_threads_runtime_support" ]
Expand Down
9 changes: 9 additions & 0 deletions jemalloc-sys/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@ This crate provides following cargo feature flags:
* `libgcc` (unless --disable-prof-libgcc)
* `gcc intrinsics` (unless --disable-prof-gcc)

* `profiling_libunwind` (configure `jemalloc` with `--enable-prof-libunwind`):
Force jemalloc to use `libunwind` for backtracing during heap profiling
instead of the default gcc-based unwinding, which has a
[known livelock bug](https://github.com/jemalloc/jemalloc/issues/2282) in
multi-threaded programs using `_Unwind_Backtrace`. Enables `profiling`
automatically. On Linux, this requires `libunwind-dev` (or `libunwind-devel`)
to be installed. On macOS/iOS, unwind symbols are provided by the system and
no extra library is needed.

* `stats` (configure `jemalloc` with `--enable-stats`): Enable statistics
gathering functionality. See the `jemalloc`'s "`opt.stats_print`" option
documentation for usage details.
Expand Down
11 changes: 11 additions & 0 deletions jemalloc-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,17 @@ fn main() {
cmd.arg("--enable-prof");
}

if env::var("CARGO_FEATURE_PROFILING_LIBUNWIND").is_ok() {
info!("CARGO_FEATURE_PROFILING_LIBUNWIND set");
cmd.arg("--enable-prof-libunwind");
// On Apple platforms unwind symbols live in libSystem, and on
// Windows libunwind is not available. Everywhere else (Linux,
// FreeBSD, etc.) we need to link it explicitly.
if !target.contains("apple") && !target.contains("windows") {
println!("cargo:rustc-link-lib=unwind");
}
}

if env::var("CARGO_FEATURE_STATS").is_ok() {
info!("CARGO_FEATURE_STATS set");
cmd.arg("--enable-stats");
Expand Down
1 change: 1 addition & 0 deletions jemallocator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ tikv-jemalloc-ctl = { path = "../jemalloc-ctl", version = "0.6.1" }
default = ["background_threads_runtime_support"]
alloc_trait = []
profiling = ["tikv-jemalloc-sys/profiling"]
profiling_libunwind = ["tikv-jemalloc-sys/profiling_libunwind", "profiling"]
debug = ["tikv-jemalloc-sys/debug"]
stats = ["tikv-jemalloc-sys/stats"]
background_threads_runtime_support = ["tikv-jemalloc-sys/background_threads_runtime_support"]
Expand Down
Loading