Skip to content

Commit cc26837

Browse files
committed
add feature flag to enable ZSTD_STATIC_LINKING_ONLY
1 parent b4887ed commit cc26837

File tree

4 files changed

+15
-0
lines changed

4 files changed

+15
-0
lines changed

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ mt_static = ["rust-librocksdb-sys/mt_static"]
3333
multi-threaded-cf = []
3434
serde1 = ["serde"]
3535
malloc-usable-size = ["rust-librocksdb-sys/malloc-usable-size"]
36+
zstd-static-linking-only = ["rust-librocksdb-sys/zstd-static-linking-only"]
3637

3738
[dependencies]
3839
libc = "0.2"

README.md

+9
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,12 @@ supported by the platform and is necessary if you want to use the
103103
malloc_usable_size being available. See
104104
[rocksdb](https://github.com/facebook/rocksdb/blob/v9.0.0/include/rocksdb/table.h#L401-L434)
105105
for more information on the feature.
106+
107+
### ZSTD Static Linking Only
108+
109+
The feature `zstd-static-linking-only` in combination with enabling zstd
110+
compression will cause Rocksdb to hold digested dictionaries in block cache to
111+
save repetitive deserialization overhead. This saves a lot of CPU for read-heavy
112+
workloads. This feature is gated behind a flag in Rocksdb because one of the
113+
digested dictionary APIs used is marked as experimental. However, this feature
114+
is still used at facebook in production per the [Preset Dictionary Compression Blog Post](https://rocksdb.org/blog/2021/05/31/dictionary-compression.html).

librocksdb-sys/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ zlib = ["libz-sys"]
4040
bzip2 = ["bzip2-sys"]
4141
rtti = []
4242
malloc-usable-size = []
43+
zstd-static-linking-only = []
4344

4445
[dependencies]
4546
libc = "0.2"

librocksdb-sys/build.rs

+4
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ fn build_rocksdb() {
7575
if let Some(path) = env::var_os("DEP_ZSTD_INCLUDE") {
7676
config.include(path);
7777
}
78+
79+
if cfg!(feature = "zstd-static-linking-only") {
80+
config.define("ZSTD_STATIC_LINKING_ONLY", Some("1"));
81+
}
7882
}
7983

8084
if cfg!(feature = "zlib") {

0 commit comments

Comments
 (0)