RocksDB: Uses lz4 compression on disk

pull/171/head
Tpt 3 years ago
parent 3119e7748e
commit f68d747308
  1. 3
      .gitmodules
  2. 6
      lib/src/storage/rocksdb_backend.rs
  3. 18
      rocksdb-sys/build.rs
  4. 1
      rocksdb-sys/lz4

3
.gitmodules vendored

@ -10,3 +10,6 @@
[submodule "rocksdb-sys/rocksdb"] [submodule "rocksdb-sys/rocksdb"]
path = rocksdb-sys/rocksdb path = rocksdb-sys/rocksdb
url = https://github.com/facebook/rocksdb/ url = https://github.com/facebook/rocksdb/
[submodule "rocksdb-sys/lz4"]
path = rocksdb-sys/lz4
url = https://github.com/lz4/lz4/

@ -105,6 +105,12 @@ impl Db {
assert!(!options.is_null(), "rocksdb_options_create returned null"); assert!(!options.is_null(), "rocksdb_options_create returned null");
rocksdb_options_set_create_if_missing(options, 1); rocksdb_options_set_create_if_missing(options, 1);
rocksdb_options_set_create_missing_column_families(options, 1); rocksdb_options_set_create_missing_column_families(options, 1);
if !in_memory {
rocksdb_options_set_compression(
options,
rocksdb_lz4_compression.try_into().unwrap(),
);
}
let txn_options = rocksdb_transactiondb_options_create(); let txn_options = rocksdb_transactiondb_options_create();
assert!( assert!(

@ -39,7 +39,9 @@ fn build_rocksdb() {
.include("rocksdb/include/") .include("rocksdb/include/")
.include("rocksdb/") .include("rocksdb/")
.file("api/c.cc") .file("api/c.cc")
.define("NDEBUG", Some("1")); .define("NDEBUG", Some("1"))
.define("LZ4", Some("1"))
.include("lz4/lib/");
let mut lib_sources = include_str!("rocksdb/src.mk") let mut lib_sources = include_str!("rocksdb/src.mk")
.split_once("LIB_SOURCES =") .split_once("LIB_SOURCES =")
@ -169,8 +171,22 @@ fn build_rocksdb() {
config.compile("rocksdb"); config.compile("rocksdb");
} }
fn build_lz4() {
let mut config = cc::Build::new();
config
.file("lz4/lib/lz4.c")
.file("lz4/lib/lz4frame.c")
.file("lz4/lib/lz4hc.c")
.file("lz4/lib/xxhash.c");
if env::var("TARGET").unwrap() == "i686-pc-windows-gnu" {
config.flag("-fno-tree-vectorize");
}
config.compile("lz4");
}
fn main() { fn main() {
println!("cargo:rerun-if-changed=api/"); println!("cargo:rerun-if-changed=api/");
bindgen_rocksdb(); bindgen_rocksdb();
build_lz4();
build_rocksdb(); build_rocksdb();
} }

@ -0,0 +1 @@
Subproject commit d44371841a2f1728a3f36839fd4b7e872d0927d3
Loading…
Cancel
Save