Skip to content

Commit 159e167

Browse files
authored
[Refactor] Remove code of cachelib (StarRocks#48859)
cachelib is useless now, so remove it. Signed-off-by: trueeyu <[email protected]>
1 parent 1e66a7a commit 159e167

17 files changed

+8
-407
lines changed

be/CMakeLists.txt

-54
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,6 @@ option(WITH_GCOV "Build binary with gcov to get code coverage" OFF)
8282

8383
option(WITH_COMPRESS "Build binary with compresss debug section" ON)
8484

85-
option(WITH_CACHELIB "Build binary with cachelib library" OFF)
86-
8785
option(WITH_STARCACHE "Build binary with starcache library" ON)
8886
option(WITH_BRCP_KEEPALIVE "Build binary with brpc_socket_keepalive (requires brpc 1.8)" OFF)
8987

@@ -412,45 +410,6 @@ if (${WITH_TENANN} STREQUAL "ON")
412410
endif()
413411
endif()
414412

415-
# cachelib
416-
set(CACHELIB_DEPENDENCIES
417-
cachelib_common
418-
cachelib_allocator
419-
cachelib_datatype
420-
cachelib_navy
421-
cachelib_shm
422-
folly
423-
fmtd
424-
thriftcpp2
425-
thrift-core
426-
thriftmetadata
427-
thriftfrozen2
428-
thriftprotocol
429-
thrifttype
430-
transport
431-
rpcmetadata
432-
thriftanyrep
433-
thrifttyperep
434-
thriftannotation
435-
concurrency
436-
async
437-
wangle
438-
)
439-
440-
if (${WITH_CACHELIB} STREQUAL "ON")
441-
LINK_LIBRARIES(${THIRDPARTY_DIR}/cachelib/deps/lib64/libunwind.so)
442-
LINK_LIBRARIES(${THIRDPARTY_DIR}/cachelib/deps/lib64/liblzma.so)
443-
foreach(dep ${CACHELIB_DEPENDENCIES})
444-
add_library(${dep} STATIC IMPORTED)
445-
set(location "${THIRDPARTY_DIR}/cachelib/lib/lib${dep}.a")
446-
if(NOT EXISTS ${location})
447-
set(location "${THIRDPARTY_DIR}/cachelib/lib64/lib${dep}.a")
448-
endif()
449-
set_target_properties(${dep} PROPERTIES IMPORTED_LOCATION "${location}")
450-
message(STATUS "add cachelib dependency: ${location}")
451-
endforeach()
452-
endif()
453-
454413
if (${WITH_STARCACHE} STREQUAL "ON")
455414
add_library(starcache STATIC IMPORTED GLOBAL)
456415
set(STARCACHE_DIR "${THIRDPARTY_DIR}/starcache")
@@ -665,9 +624,6 @@ set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -Werror=return-type -Werror=switch")
665624
if (${USE_STAROS} STREQUAL "ON")
666625
set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -DUSE_STAROS")
667626
endif()
668-
if (${WITH_CACHELIB} STREQUAL "ON")
669-
set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -DWITH_CACHELIB")
670-
endif()
671627
if (${WITH_STARCACHE} STREQUAL "ON")
672628
set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -DWITH_STARCACHE")
673629
endif()
@@ -936,16 +892,6 @@ set(STARROCKS_DEPENDENCIES
936892
${WL_END_GROUP}
937893
)
938894

939-
if (${WITH_CACHELIB} STREQUAL "ON")
940-
set(STARROCKS_DEPENDENCIES
941-
${STARROCKS_DEPENDENCIES}
942-
${WL_START_GROUP}
943-
${Boost_LIBRARIES}
944-
${CACHELIB_DEPENDENCIES}
945-
${WL_END_GROUP}
946-
)
947-
endif()
948-
949895
if (${WITH_STARCACHE} STREQUAL "ON")
950896
set(STARROCKS_DEPENDENCIES
951897
${STARROCKS_DEPENDENCIES}

be/src/bench/block_cache_bench.cpp

+1-31
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,6 @@
3232
#include "util/logging.h"
3333
#include "util/random.h"
3434
#include "util/time.h"
35-
#ifdef WITH_CACHELIB
36-
#include "block_cache/cachelib_wrapper.h"
37-
#endif
3835

3936
namespace starrocks {
4037

@@ -50,12 +47,9 @@ void delete_dir_content(const std::string& dir_path) {
5047
}
5148
}
5249

53-
enum class CacheEngine { CACHELIB, STARCACHE };
54-
5550
class BlockCacheBenchSuite {
5651
public:
5752
struct BenchParams {
58-
CacheEngine cache_engine;
5953
size_t obj_count = 0;
6054
size_t obj_key_size = 0;
6155
size_t obj_value_size = 0;
@@ -115,16 +109,7 @@ class BlockCacheBenchSuite {
115109

116110
BlockCacheBenchSuite(const CacheOptions& options, const BenchParams& params) {
117111
_params = new BlockCacheBenchSuite::BenchParams(params);
118-
if (params.cache_engine == CacheEngine::STARCACHE) {
119-
_cache = new StarCacheWrapper;
120-
#ifdef WITH_CACHELIB
121-
} else {
122-
_cache = new CacheLibWrapper;
123-
#endif
124-
}
125-
else {
126-
DCHECK(false) << "Unsupported cache engine: " << params.cache_engine;
127-
}
112+
_cache = new StarCacheWrapper;
128113
Status st = _cache->init(options);
129114
DCHECK(st.ok()) << st.message();
130115
_ctx = new BenchContext();
@@ -283,17 +268,9 @@ static void do_bench_cache(benchmark::State& state, const CacheOptions& options,
283268
//state.counters["read_throught"] = suite->ctx()->read_throught->get_value();
284269
}
285270

286-
template <class... Args>
287-
static void BM_bench_cachelib(benchmark::State& state, Args&&... args) {
288-
auto args_tuple = std::make_tuple(std::move(args)...);
289-
std::get<0>(args_tuple).second.cache_engine = CacheEngine::CACHELIB;
290-
do_bench_cache(state, std::get<0>(args_tuple).first, std::get<0>(args_tuple).second);
291-
}
292-
293271
template <class... Args>
294272
static void BM_bench_starcache(benchmark::State& state, Args&&... args) {
295273
auto args_tuple = std::make_tuple(std::move(args)...);
296-
std::get<0>(args_tuple).second.cache_engine = CacheEngine::STARCACHE;
297274
do_bench_cache(state, std::get<0>(args_tuple).first, std::get<0>(args_tuple).second);
298275
}
299276

@@ -391,13 +368,6 @@ BENCHMARK_CAPTURE(BM_bench_starcache, bench_read_write_remove_disk, read_write_r
391368
// Random offset for Read+Write+Remove Disk
392369
BENCHMARK_CAPTURE(BM_bench_starcache, bench_random_offset_read, random_offset_read_suite())->Threads(16);
393370

394-
#ifdef WITH_CACHELIB
395-
BENCHMARK_CAPTURE(BM_bench_cachelib, bench_read_mem, read_mem_suite())->Threads(16);
396-
BENCHMARK_CAPTURE(BM_bench_cachelib, bench_read_disk, read_disk_suite())->Threads(16);
397-
BENCHMARK_CAPTURE(BM_bench_cachelib, bench_read_write_remove_disk, read_write_remove_disk_suite())->Threads(16);
398-
BENCHMARK_CAPTURE(BM_bench_cachelib, bench_random_offset_read, random_offset_read_suite())->Threads(16);
399-
#endif
400-
401371
} // namespace starrocks
402372

403373
//BENCHMARK_MAIN();

be/src/block_cache/CMakeLists.txt

-13
Original file line numberDiff line numberDiff line change
@@ -31,23 +31,10 @@ set(CACHE_FILES
3131
block_cache_hit_rate_counter.hpp
3232
)
3333

34-
if (${WITH_CACHELIB} STREQUAL "ON")
35-
list(APPEND CACHE_FILES cachelib_wrapper.cpp)
36-
endif()
37-
3834
if (${WITH_STARCACHE} STREQUAL "ON")
3935
list(APPEND CACHE_FILES starcache_wrapper.cpp)
4036
endif()
4137

4238
add_library(BlockCache STATIC
4339
${CACHE_FILES}
4440
)
45-
46-
if (${WITH_CACHELIB} STREQUAL "ON")
47-
set(CACHELIB_DIR ${THIRDPARTY_DIR}/cachelib)
48-
link_directories(${CACHELIB_DIR}/deps/lib64)
49-
50-
include_directories(AFTER ${CACHELIB_DIR}/include)
51-
include_directories(AFTER ${CACHELIB_DIR}/deps/include)
52-
endif()
53-

be/src/block_cache/block_cache.cpp

-14
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,9 @@
1616

1717
#include <fmt/format.h>
1818

19-
#include <filesystem>
20-
21-
#ifdef WITH_CACHELIB
22-
#include "block_cache/cachelib_wrapper.h"
23-
#endif
2419
#ifdef WITH_STARCACHE
2520
#include "block_cache/starcache_wrapper.h"
2621
#endif
27-
#include "common/config.h"
2822
#include "common/logging.h"
2923
#include "common/statusor.h"
3024
#include "gutil/strings/substitute.h"
@@ -33,8 +27,6 @@ namespace starrocks {
3327

3428
namespace fs = std::filesystem;
3529

36-
// The cachelib doesn't support a item (key+valueu+attribute) larger than 4 MB without chain.
37-
// So, we check and limit the block_size configured by users to avoid unexpected errors.
3830
// For starcache, in theory we doesn't have a hard limitation for block size, but a very large
3931
// block_size may cause heavy read amplification. So, we also limit it to 2 MB as an empirical value.
4032
const size_t BlockCache::MAX_BLOCK_SIZE = 2 * 1024 * 1024;
@@ -51,12 +43,6 @@ BlockCache::~BlockCache() {
5143
Status BlockCache::init(const CacheOptions& options) {
5244
_block_size = std::min(options.block_size, MAX_BLOCK_SIZE);
5345
auto cache_options = options;
54-
#ifdef WITH_CACHELIB
55-
if (cache_options.engine == "cachelib") {
56-
_kv_cache = std::make_unique<CacheLibWrapper>();
57-
LOG(INFO) << "init cachelib engine, block_size: " << _block_size;
58-
}
59-
#endif
6046
#ifdef WITH_STARCACHE
6147
if (cache_options.engine == "starcache") {
6248
_kv_cache = std::make_unique<StarCacheWrapper>();

be/src/block_cache/cachelib_wrapper.cpp

-147
This file was deleted.

0 commit comments

Comments
 (0)