Skip to content

Commit

Permalink
actually enable jemalloc when feature is used on linux
Browse files Browse the repository at this point in the history
  • Loading branch information
zaidoon1 committed Feb 26, 2024
1 parent 528bbed commit 10fd9af
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion librocksdb-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ exclude = [

[features]
default = ["static"]
jemalloc = ["tikv-jemalloc-sys"]
jemalloc = ["tikv-jemalloc-sys", "pkg-config"]
static = ["libz-sys?/static", "bzip2-sys?/static"]
io-uring = ["pkg-config"]
snappy = []
Expand Down
15 changes: 13 additions & 2 deletions librocksdb-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,19 @@ fn build_rocksdb() {

config.define("ROCKSDB_SUPPORT_THREAD_LOCAL", None);

if cfg!(feature = "jemalloc") {
config.define("WITH_JEMALLOC", "ON");
#[cfg(feature = "jemalloc")]
{
if target.contains("linux") {
pkg_config::probe_library("libjemalloc-dev")
.expect("The jemalloc feature was requested but libjemalloc-dev is not installed");
config.define("ROCKSDB_JEMALLOC", Some("1"));
config.define("JEMALLOC_NO_DEMANGLE", Some("1"));
} else {
// this doesn't actually enable jemalloc, but mac/windows needs more
// work to make it work (statically link tikv-jemalloc). For now,
// I'll keep this as is.
config.define("WITH_JEMALLOC", "ON");
}
}

#[cfg(feature = "io-uring")]
Expand Down

0 comments on commit 10fd9af

Please sign in to comment.