Skip to content
Prev Previous commit
Next Next commit
Add README, fix test issue
  • Loading branch information
mrambacher committed Dec 23, 2022
commit 28a8ae3acbf024edfe2ebb4977077142edcc876e
44 changes: 44 additions & 0 deletions cachelib/adaptor/rocks_secondary_cache/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# RocksDB CacheLib Secondary Cache

This directory contains files and tests for building Cachelib as a SecondaryCache for RocksDB.

# Build

Currently the build is only supported via cmake.

First, build cachelib through the normal build procedure.

To build under RocksDB, link this directory adaptor/rocksdb_secondary_cache) to the plugins/cachelib directory under RocksDB:
```
$ln -s .../secondary_cache .../plugins/cachelib).
```
This will allow RocksDB to find and build the CacheLib plugin code.

Next, under the RocksDB build directory, instruct RocksDB to build and include the cachelib plugin:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious, how is the folly dependency handled? Should the user do this first - https://github.com/facebook/rocksdb/wiki/RocksDB-Contribution-Guide#build-rocksdb-with-folly-integration-enabled?

```
$cmake -DROCKSDB_PLUGINS=cachelib -DCMAKE_PREFIX_PATH=<Path to CacheLib> -DCMAKE_MODULE_PATH="<Path to CacheLib>" -DWITH_GFLAGS=OFF ..
```
where the prefix path points to the opt/cachelib directory and module path points to the cachelib/cmake directory.

Finally, build RocksDB using "make".

# Using the RocksDB Cachelib Secondary Cache

The Secondary Cache can be created via either the SecondaryCache::CreateFromString or NewRocksCachelibWrapper APIs.
```
SecondaryCache::CreateFromString(..., "id=RocksCachelibWrapper; ...");

RoksCachelibOptions options;
NewRocksCachelibWrapper(options);
```

When using CreateFromString API, the options can be specified as name-value pairs on the command line. The mapping between the field names and options is found in CacheLibWrapper.cpp.

# Issues and TODO

* There are incompatibilities between RocksDB and Cachelib on the version of GTEST required and supported. In order to successfully build, you must use the GTEST version in Cachelib and remove the gtest from the RocksDB build. This requirement is true whether or not you are building tests. In the RocksDB build, you must remove GTEST from the "include_directories" and "add_subdirectories" and add " -Wno-error=deprecated-declarations" to the CMAKE_CXX_FLAGS. You may also need to add "-Wno-error=sign-compare" to build the RocksDB tests, depending on your compiler.

* RocksDB does not currently enable plugins to build their own tests (see PR11052). When the CachelibWrapperTest is added, additional link libraries may be required (See the CMakeLists.txt file). No investigation as to the reason has been undertaken.



Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ TEST_F(CachelibWrapperTest, CreateFromString) {
"region_size=4096;"
"volatile_size=1024;"
"policy=unknown;"
"probablity=0.42;"
"probability=0.42;"
"max_write_rate=11;"
"admission_write_rate=22;"
"bucket_power=48;"
Expand Down