Skip to content
Permalink
Browse files

Resolves #866

- Restores the WITH_LZ4 option in the main CMakeLists.txt
- Carries the WITH_LZ4 flag to the non-MSVC build process for RocksDB instead of always setting to ON
- Updates RocksDB CMakeLists.txt to indicate whether it is building with LZ4 support or not
- Sets a new definition that is used in DaemonConfiguration.cpp to define whether to allow --db-enable-compression option
  • Loading branch information...
brandonlehmann committed Aug 27, 2019
1 parent 190234e commit 642def258fc375d1059fd0e3eb7fda0598f24df1
Showing with 40 additions and 21 deletions.
  1. +8 −1 CMakeLists.txt
  2. +2 −0 external/rocksdb/CMakeLists.txt
  3. +30 −20 src/daemon/DaemonConfiguration.cpp
@@ -58,6 +58,9 @@ set(FORCE_USE_HEAP ON CACHE BOOL "Force the use of heap memory allocation")
set(NO_AES OFF CACHE BOOL "Turn off Hardware AES instructions?")
set(NO_OPTIMIZED_MULTIPLY_ON_ARM OFF CACHE BOOL "Turn off Optimized Multiplication on ARM?")

## This section defines a few parameters that we open up for use with RocksDB
set(WITH_LZ4 ON CACHE STRING "Enable lz4 compression")

message(STATUS "Building for target architecture: ${ARCH}")

if (FORCE_USE_HEAP)
@@ -81,6 +84,10 @@ else ()
message(STATUS "OPTIMIZED_ARM_MULTIPLICATION: ENABLED")
endif ()

if (WITH_LZ4)
add_definitions(-DENABLE_LZ4_COMPRESSION)
endif ()

# We need to set the label and import it into CMake if it exists
set(LABEL "")
if (DEFINED ENV{LABEL})
@@ -288,7 +295,7 @@ add_subdirectory(src)
## We need to setup the RocksDB build environment to match our system
if (NOT MSVC)
execute_process(
COMMAND cmake ${CMAKE_CURRENT_SOURCE_DIR}/external/rocksdb -DARCH=${ARCH} -DWITH_LZ4=ON -DWITH_GFLAGS=0 -DCMAKE_BUILD_TYPE=MinSizeRel -DWITH_TESTS=OFF -DWITH_TOOLS=OFF -DPORTABLE=ON -B${PROJECT_BINARY_DIR}/rocksdb
COMMAND cmake ${CMAKE_CURRENT_SOURCE_DIR}/external/rocksdb -DARCH=${ARCH} -DWITH_LZ4=${WITH_LZ4} -DWITH_GFLAGS=0 -DCMAKE_BUILD_TYPE=MinSizeRel -DWITH_TESTS=OFF -DWITH_TOOLS=OFF -DPORTABLE=ON -B${PROJECT_BINARY_DIR}/rocksdb
)
set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${PROJECT_BINARY_DIR}/rocksdb/librocksdb.a")
endif ()
@@ -67,6 +67,7 @@ if(MSVC)
include(${CMAKE_CURRENT_SOURCE_DIR}/thirdparty.inc)

if(WITH_LZ4)
message(STATUS "LZ4 library is enabled")
SET(LZ4_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../lz4")
SET(LZ4_LIBRARIES lz4)
add_definitions(-DLZ4)
@@ -121,6 +122,7 @@ else()
endif()

if(WITH_LZ4)
message(STATUS "LZ4 library is enabled")
SET(LZ4_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../lz4")
SET(LZ4_LIBRARIES lz4)
add_definitions(-DLZ4)
@@ -156,26 +156,28 @@ namespace DaemonConfig
cxxopts::value<std::vector<std::string>>(),
"<ip:port>");

options.add_options("Database")(
"db-enable-compression",
"Enable database compression",
cxxopts::value<bool>(config.enableDbCompression)->default_value("false")->implicit_value("true"))(
"db-max-open-files",
"Number of files that can be used by the database at one time",
cxxopts::value<int>()->default_value(std::to_string(config.dbMaxOpenFiles)),
"#")(
"db-read-buffer-size",
"Size of the database read cache in megabytes (MB)",
cxxopts::value<int>()->default_value(std::to_string(config.dbReadCacheSizeMB)),
"#")(
"db-threads",
"Number of background threads used for compaction and flush operations",
cxxopts::value<int>()->default_value(std::to_string(config.dbThreads)),
"#")(
"db-write-buffer-size",
"Size of the database write buffer in megabytes (MB)",
cxxopts::value<int>()->default_value(std::to_string(config.dbWriteBufferSizeMB)),
"#");
options.add_options("Database")
#ifdef ENABLE_LZ4_COMPRESSION
("db-enable-compression",
"Enable database compression",
cxxopts::value<bool>(config.enableDbCompression)->default_value("false")->implicit_value("true"))
#endif
("db-max-open-files",
"Number of files that can be used by the database at one time",
cxxopts::value<int>()->default_value(std::to_string(config.dbMaxOpenFiles)),
"#")(
"db-read-buffer-size",
"Size of the database read cache in megabytes (MB)",
cxxopts::value<int>()->default_value(std::to_string(config.dbReadCacheSizeMB)),
"#")(
"db-threads",
"Number of background threads used for compaction and flush operations",
cxxopts::value<int>()->default_value(std::to_string(config.dbThreads)),
"#")(
"db-write-buffer-size",
"Size of the database write buffer in megabytes (MB)",
cxxopts::value<int>()->default_value(std::to_string(config.dbWriteBufferSizeMB)),
"#");

try
{
@@ -263,10 +265,12 @@ namespace DaemonConfig
config.useRocksdbForLocalCaches = cli["rocksdb"].as<bool>();
}

#ifdef ENABLE_LZ4_COMPRESSION
if (cli.count("db-enable-compression") > 0)
{
config.enableDbCompression = cli["db-enable-compression"].as<bool>();
}
#endif

if (cli.count("no-console") > 0)
{
@@ -474,11 +478,13 @@ namespace DaemonConfig
config.useRocksdbForLocalCaches = cfgValue.at(0) == '1';
updated = true;
}
#ifdef ENABLE_LZ4_COMPRESSION
else if (cfgKey.compare("db-enable-compression") == 0)
{
config.enableDbCompression = cfgValue.at(0) == '1';
updated = true;
}
#endif
else if (cfgKey.compare("no-console") == 0)
{
config.noConsole = cfgValue.at(0) == '1';
@@ -722,10 +728,12 @@ namespace DaemonConfig
config.useRocksdbForLocalCaches = j["rocksdb"].GetBool();
}

#ifdef ENABLE_LZ4_COMPRESSION
if (j.HasMember("db-enable-compression"))
{
config.enableDbCompression = j["db-enable-compression"].GetBool();
}
#endif

if (j.HasMember("no-console"))
{
@@ -866,7 +874,9 @@ namespace DaemonConfig
j.AddMember("no-console", config.noConsole, alloc);
j.AddMember("rocksdb", config.useRocksdbForLocalCaches, alloc);
j.AddMember("sqlite", config.useSqliteForLocalCaches, alloc);
#ifdef ENABLE_LZ4_COMPRESSION
j.AddMember("db-enable-compression", config.enableDbCompression, alloc);
#endif
j.AddMember("db-max-open-files", config.dbMaxOpenFiles, alloc);
j.AddMember("db-read-buffer-size", (config.dbReadCacheSizeMB), alloc);
j.AddMember("db-threads", config.dbThreads, alloc);

0 comments on commit 642def2

Please sign in to comment.
You can’t perform that action at this time.