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 e32c069
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ jobs:
- name: Install dependencies
if: runner.os == 'Windows'
run: choco install llvm -y

- name: Install dependencies (Linux)
if: runner.os == 'Linux'
run: sudo apt-get install libjemalloc-dev

- name: Run rocksdb tests
run: |
Expand Down
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("jemalloc")
.expect("The jemalloc feature was requested but jemalloc 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 e32c069

Please sign in to comment.