-
Notifications
You must be signed in to change notification settings - Fork 452
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
Support to use lz4 compression in RocksDB #584
Conversation
The biggest problem we need to solve is how to compile these compression algorithms. |
5d5e108
to
f1d605c
Compare
Do guys think this change makes sense for Kvrocks? |
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.
Great job! Thanks for your hard work. Comments inline.
cmake/lz4.cmake
Outdated
if (EXISTS ${LZ4_ZIP_ABSOLUT_PATH}) | ||
file(MD5 ${LZ4_ZIP_ABSOLUT_PATH} LZ4_MD5SUM_) | ||
if (NOT ${LZ4_MD5SUM} STREQUAL ${LZ4_MD5SUM_}) | ||
message(STATUS "remove -f ${LZ4_ZIP_ABSOLUT_PATH}") | ||
execute_process(COMMAND sh -c "rm -f ${LZ4_ZIP_ABSOLUT_PATH}") | ||
endif() | ||
endif() | ||
|
||
if (NOT EXISTS ${LZ4_ZIP_ABSOLUT_PATH}) | ||
# download | ||
message(STATUS "Downloading ${LZ4_ZIP_NAME} to ${LZ4_ZIP_ABSOLUT_PATH}") | ||
file(DOWNLOAD ${LZ4_DOWNLOAD_URL} | ||
${LZ4_ZIP_ABSOLUT_PATH} | ||
TIMEOUT ${DOWNLOAD_LZ4_TIMEOUT} | ||
STATUS ERR SHOW_PROGRESS) | ||
endif() | ||
|
||
if (EXISTS ${LZ4_ZIP_ABSOLUT_PATH}) | ||
file(MD5 ${LZ4_ZIP_ABSOLUT_PATH} LZ4_MD5SUM_) | ||
if (NOT ${LZ4_MD5SUM} STREQUAL ${LZ4_MD5SUM_}) | ||
message(FATAL_ERROR "${LZ4_ZIP_ABSOLUT_PATH} seems be something wrong, please check") | ||
endif() | ||
else() | ||
message(FATAL_ERROR "${LZ4_ZIP_ABSOLUT_PATH} seems be something wrong, please check") | ||
endif() |
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.
Could you use FetchContent instead of these manual downloading commands?
Just like lua.cmake, it is easy to maintain and more straightforward.
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 dirs are under GPL license except the lib which we are needed, so NOT sure whether is it ok to use FetchContent
like others.
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.
We can just fetch files and do not call add_subdirectory
(do not use these cmake files in lz4), like in lua.cmake
, so I think it has few difference on the license issue than the manual way.
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.
To facilitate the modification, I show a concrete example below:
FetchContent_Declare(lz4
URL https://github.com/lz4/lz4/archive/v1.9.3.tar.gz
)
FetchContent_GetProperties(lz4)
if(NOT lz4_POPULATED)
FetchContent_Populate(lz4)
add_custom_target(make_lz4 COMMAND make ...)
...
endif()
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.
cool, thanks for Twice's explain.
cmake/lz4.cmake
Outdated
message(STATUS "remove ${LZ4_SOURCE_DIR}") | ||
execute_process(COMMAND sh -c "rm -rf ${LZ4_SOURCE_DIR}") |
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.
I think these commands are not friendly to incremental build, could you consider to remove them?
We can use FetchContent to manipulate these file system stuff automatically.
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.
Cool
cmake/rocksdb.cmake
Outdated
lz4_ROOT_DIR=${LZ4_LIB_SOURCE_DIR} | ||
lz4_LIBRARIES=${LZ4_LIB_SOURCE_DIR}/liblz4.a | ||
lz4_INCLUDE_DIRS=${LZ4_LIB_SOURCE_DIR} |
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.
Like cmake files in cmake/modules, injecting the lz4 target via hooking find package mechanism can propagate dependency relation into the rocksdb target, in addition this makes the dependencies more modular, we can easily do some switches to selectively enable them.
Of course, if you are not familiar with them, I can follow up to help you implement them : )
1. make lz4.cmake more cmake style
59afeaf
to
432a1b5
Compare
The unit test failed in https://github.com/apache/incubator-kvrocks/runs/7003199495?check_suite_focus=true for 1ee66be. |
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.
LGTM. cc @git-hulk @tisonkun @ShooterIT
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.
Cool! Is there any test coverage for lz4 compression option? Or do you verify it locally?
I tested it on my side, run with LZ4 is ok and check the symbols: 000000000072a890 t LZ4HC_compress_generic_dictCtx
0000000000725ec0 t LZ4HC_compress_generic_noDictCtx.part.0
00000000007216f0 t LZ4HC_compress_optimal
0000000000730790 T LZ4_attach_HC_dictionary
0000000000714790 T LZ4_attach_dictionary
0000000000721590 T LZ4_compress
000000000070b9a0 T LZ4_compressBound
0000000000730be0 T LZ4_compressHC
0000000000730ec0 T LZ4_compressHC2
00000000007319f0 T LZ4_compressHC2_continue
... |
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.
@git-hulk thanks for your input. +1 to merge.
BTW do you confirm that introduce lz4 support in this way won't cause dependency issue? IIRC lz4 can contain GPLv2 code, but if we use lib
only, it should be fine.
Yes that we use |
Yeah, I think this way only uses files in the |
So, let's merge this PR if this's crystal clear. cc @tisonkun @PragmaTwice @ShooterIT |
Thanks for @xiaobiaozhao contribution again! |
Description
Why need the PR?
Provides more Rocksdb.compression configuration parameters for customization
This closes #601