Skip to content

Commit

Permalink
Add jemalloc feature (rust-rocksdb#319)
Browse files Browse the repository at this point in the history
Adding feature "jemalloc". When enabled, rocksdb "WITH_JEMALLOC" will be enabled. This does NOT affect whether jemalloc is use or not. Mostly it only affect how rocksdb calculate block cache size: if "WITH_JEMALLOC" is on, it will use `malloc_usable_size()` (size allocated by jemalloc) to calculate size of each entry of block cache, instead of the requested size of the allocation.

Tested by running `cargo build --features jemalloc -vv` and check rocksdb compile flags from the output.

Signed-off-by: Yi Wu <yiwu@pingcap.com>
  • Loading branch information
yiwu-arbug committed Jul 22, 2019
1 parent 5686568 commit d67f38e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ exclude = [

[features]
default = []
valgrind = []
jemalloc = ["librocksdb_sys/jemalloc"]
portable = ["librocksdb_sys/portable"]
sse = ["librocksdb_sys/sse"]
valgrind = []

[dependencies]
libc = "0.2.11"
Expand Down
1 change: 1 addition & 0 deletions librocksdb_sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ tempdir = "0.3"

[features]
default = []
jemalloc = []
# portable doesn't require static link, though it's meaningless
# when not using with static-link right now in this crate.
portable = ["libtitan_sys/portable"]
Expand Down
3 changes: 3 additions & 0 deletions librocksdb_sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ fn build_rocksdb() -> Build {
}

let mut cfg = Config::new("rocksdb");
if cfg!(feature = "jemalloc") {
cfg.define("WITH_JEMALLOC", "ON");
}
if cfg!(feature = "portable") {
cfg.define("PORTABLE", "ON");
}
Expand Down

0 comments on commit d67f38e

Please sign in to comment.