Commit 9603a845 authored by Wu Jiayu's avatar Wu Jiayu Committed by Connor

Fix jemalloc allocator (#332)

* fix memory allocator
parent cf083fa6
......@@ -25,8 +25,9 @@ cc = "1.0.3"
cmake = "0.1"
[dependencies.jemalloc-sys]
version = ">= 0.1.8"
version = "0.1.8"
optional = true
features = ["unprefixed_malloc_on_supported_platforms"]
[dependencies.libz-sys]
version = "1.0.25"
......
......@@ -80,6 +80,7 @@ fn build_rocksdb() -> Build {
let mut cfg = Config::new("rocksdb");
if cfg!(feature = "jemalloc") && NO_JEMALLOC_TARGETS.iter().all(|i| !target.contains(i)) {
cfg.register_dep("JEMALLOC").define("WITH_JEMALLOC", "ON");
println!("cargo:rustc-link-lib=static=jemalloc");
}
if cfg!(feature = "portable") {
cfg.define("PORTABLE", "ON");
......
......@@ -354,7 +354,9 @@ extern "C" {
) -> *mut Options;
// Memory Allocator
pub fn crocksdb_jemalloc_nodump_allocator_create() -> *mut DBMemoryAllocator;
pub fn crocksdb_jemalloc_nodump_allocator_create(
err: *mut *mut c_char,
) -> *mut DBMemoryAllocator;
pub fn crocksdb_memory_allocator_destroy(allocator: *mut DBMemoryAllocator);
// Cache
......
......@@ -2386,7 +2386,7 @@ impl MemoryAllocator {
pub fn new_jemalloc_memory_allocator() -> Result<MemoryAllocator, String> {
unsafe {
let allocator = MemoryAllocator {
inner: ffi_try!(crocksdb_ffi::crocksdb_jemalloc_nodump_allocator_create()),
inner: ffi_try!(crocksdb_jemalloc_nodump_allocator_create()),
};
Ok(allocator)
}
......
......@@ -1878,7 +1878,7 @@ impl LRUCacheOptions {
}
}
pub fn set_memory_allocator(&mut self, allocator: &MemoryAllocator) {
pub fn set_memory_allocator(&mut self, allocator: MemoryAllocator) {
unsafe {
crocksdb_ffi::crocksdb_lru_cache_options_set_memory_allocator(
self.inner,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment