-
Notifications
You must be signed in to change notification settings - Fork 312
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rocksdb: add compression type zstd and lz4 #217
Conversation
lz4 is a compression algorithm with more moderate ratio? |
https://github.com/facebook/rocksdb/wiki/Compression |
看起来lz4无论在压缩率还是速度上都优于snappy,为何感觉snappy更受欢迎呢? |
rocksdb 默认用 snappy 是为了数据兼容性。snappy 跟 zlib 比起来确实更好,但是 lz4/zstd 比 snappy 更年轻自然也更优。
跟 zstd 的测试结果还是一致的,zstd 的 benchmark 用的也是 lzbench |
看来以后我们线上默认用lz4更合适 |
if (compression_str == "none") { | ||
_db_opts.compression = rocksdb::kNoCompression; | ||
} else if (compression_str == "snappy") { | ||
_db_opts.compression = rocksdb::kSnappyCompression; | ||
} else if (compression_str == "zstd") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里仅仅增加这几行代码还不够吧,还要在依赖库的链接上把这两种压缩也加进来
之前看了下线上机器,很多都没装lz4/zstd库。要上的话需要提前都装好 |
或者在pack_server的时候,把lz4/zstd库都带上 |
- sudo apt-get -y install libsnappy-dev | ||
- sudo apt-get -y install libgflags-dev | ||
- wget https://github.com/facebook/zstd/archive/v1.3.7.zip; unzip v1.3.7; cd zstd-1.3.7; | ||
- mkdir cmake-build; cd cmake-build; cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_INSTALL_LIBDIR=lib -DZSTD_BUILD_PROGRAMS=OFF ../build/cmake; sudo make install -j8; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
为什么多个shell语句有放在一行?分开放更合理吧?
Former-commit-id: fd79b03bbec5acb93a7195b955c86176c9ba8236 [formerly d0b6530] Former-commit-id: c0e1608ee7777a999d97eb9985c1750eb17b873a
In brief, if have lots of free CPU, ZSTD is a good chooice; otherwise, LZ4 is recommended.
RocksDB gives some suggestion here:
as we can see from the above table, lz4 is a compression algorithm with more moderate ratio and speed than zstd, so we also take it into consideration.
In this PR we disabled rocksdb's link with bzip2 (because we never use this lib for compression before), and add links with zstd and lz4. This two libs will be packed up using
./run.sh pack_server
and./run.sh pack_tools
.