diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 07311fb..20fe46d 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -99,3 +99,9 @@ jobs: with: command: test args: --features multi-threaded-cf + - name: Run rocksdb tests (jemalloc) + if: runner.os != 'Windows' + uses: actions-rs/cargo@v1 + with: + command: test + args: --features jemalloc diff --git a/Cargo.toml b/Cargo.toml index 7a5b880..9c8d487 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,6 +18,7 @@ exclude = [ [features] default = ["snappy", "lz4", "zstd", "zlib", "bzip2"] +jemalloc = ["librocksdb-sys/jemalloc"] valgrind = [] snappy = ["librocksdb-sys/snappy"] lz4 = ["librocksdb-sys/lz4"] diff --git a/librocksdb-sys/Cargo.toml b/librocksdb-sys/Cargo.toml index 06f2012..e4d880e 100644 --- a/librocksdb-sys/Cargo.toml +++ b/librocksdb-sys/Cargo.toml @@ -13,6 +13,7 @@ links = "rocksdb" [features] default = [ "static" ] +jemalloc = ["jemalloc-sys"] static = [] snappy = [] lz4 = [] @@ -22,6 +23,7 @@ bzip2 = [] [dependencies] libc = "0.2" +jemalloc-sys = { version = "0.3", features = ["unprefixed_malloc_on_supported_platforms"], optional = true } [dev-dependencies] const-cstr = "0.3" diff --git a/librocksdb-sys/build.rs b/librocksdb-sys/build.rs index e41065e..e018b4e 100644 --- a/librocksdb-sys/build.rs +++ b/librocksdb-sys/build.rs @@ -187,6 +187,10 @@ fn build_rocksdb() { config.define("ROCKSDB_SUPPORT_THREAD_LOCAL", None); + if cfg!(feature = "jemalloc") { + config.define("WITH_JEMALLOC", "ON"); + } + if target.contains("msvc") { config.flag("-EHsc"); } else {