zhichao-cao / SpanDB

A Fast, Cost-Effective LSM-tree Based KV Store on Hybrid Storage

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SpanDB: A Fast, Cost-Effective LSM-tree Based KV Store on Hybrid Storage

1. Install SpanDB

Upgrade your gcc to version at least 4.8 to get C++11 support

Install SPDK

Download SPDK

git clone https://github.com/spdk/spdk
cd spdk
git checkout v20.01.x
git submodule update --init

Compile SPDK

# install dependencies
sudo ./scripts/pkgdep.sh
# compile spdk
./configure --with-shared
make
sudo make install

Once installed, please add the include path for spdk to your CPATH environment variable and the lib path to LIBRARY_PATH. E.g.,

echo "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib:$PWD/dpdk/build/lib/" >> ~/.bashrc

Add dpdk environment,

echo "export DPDK_LIB=$PWD/dpdk/build/lib" >> ~/.bashrc
echo "export DPDK_INCLUDE=$PWD/dpdk/build/include" >> ~/.bashrc
source ~/.bashrc 

Before running an SPDK application, some hugepages must be allocated and any NVMe and I/OAT devices must be unbound from the native kernel drivers. SPDK includes a script to automate this process on both Linux and FreeBSD. This script should be run as root. It only needs to be run once on the system.

By default, the script allocates 2048MB of hugepages. To change this number, specify HUGEMEM (in MB) as follows:

sudo HUGEMEM=4096 scripts/setup.sh

In SpanDB, it relies on the hugepages to build it's cache. Please make sure the HUGEMEM is bigger than the size that you want to allocate for SpanDB's cache.

Install other libraries

  • Upgrade your gcc to version at least 4.8 to get C++11 support.

  • upgrade your cmake to version at least 3.5

  • Linux - Ubuntu

    • Install gflags. First, try: sudo apt-get install libgflags-dev If this doesn't work and you're using Ubuntu, here's a nice tutorial: (http://askubuntu.com/questions/312173/installing-gflags-12-04)
    • Install snappy. This is usually as easy as: sudo apt-get install libsnappy-dev.
    • Install zlib. Try: sudo apt-get install zlib1g-dev.
    • Install bzip2: sudo apt-get install libbz2-dev.
    • Install lz4: sudo apt-get install liblz4-dev.
    • Install zstandard: sudo apt-get install libzstd-dev.
    • Install tbb: sudo apt-get install libtbb-dev
  • Linux - CentOS / RHEL

    • Install gflags:

          git clone https://github.com/gflags/gflags.git
          cd gflags
          git checkout v2.0
          ./configure && make && sudo make install
      

      Notice: Once installed, please add the include path for gflags to your CPATH environment variable and the lib path to LIBRARY_PATH. If installed with default settings, the include path will be /usr/local/include and the lib path will be /usr/local/lib.

    • Install zstandard:

         wget https://github.com/facebook/zstd/archive/v1.1.3.tar.gz
         mv v1.1.3.tar.gz zstd-1.1.3.tar.gz
         tar zxvf zstd-1.1.3.tar.gz
         cd zstd-1.1.3
         make && sudo make install
      
    • Install others

        sudo yum install snappy snappy-devel zlib zlib-devel bzip2 bzip2-devel lz4-devel libasan tbb-devel
      

Install SpanDB

git clone https://github.com/SpanDB/SpanDB.git
cd SpanDB
mkdir build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX:PATH=. -DWITH_TESTS=OFF -DCMAKE_BUILD_TYPE=Release -DUSE_RTTI=true -DFAIL_ON_WARNINGS=false
make -j$(nproc)
make install

2. How to Test SpanDB

Compile YCSB

cd SpanDB/ycsb
mkdir build
cd build
cmake ../
make

Before testing SpanDB or RocksDB, we need to generate a database that used for the test. During the YCSB test, we can first copy the database to the specific directory and run workloads on this database.

After compilation, you can get the execution file file test.

The test needs 7 parameters, <workload_file> <client_num> <data_dir> <log_dir> <is_load> <dbname> <db_bak>,

  • workload_file: workload file, they are located in ycsb/workloads
  • client_num: the number of clients
  • data_dir: the directory that used for storing data
  • log_dir: the directory that used for storing WAL. If the dbname=spandb, log_dir should be the pcie addr of the NVMe SSD that used for WAL, e.g., traddr:0000:c9:00.0
  • is_load: 1 or 0, 1 means it will generate a new database, 0 means it's used for running workloads.
  • dbname: rocksdb or spandb, means it will run rocksdb or spandb
  • db_bak: where is the base DB that used for test. If is_load=1, this parameter will be ignored. If is_load=0, it will copy the database from db_bak to data_dir for the following testing.

Generate DB

./test $WORKLOAD_PATH 40 $DATA_PATA $LOG_PATA 1 rocksdb $BASE_DB_PATH

Test

RocksDB:

./test $WORKLOAD_PATH 40 $DATA_PATA $LOG_PATA 0 rocksdb $BASE_DB_PATH

SpanDB:

sudo su root
ulimit -n 100000
./test $WORKLOAD_PATH 8 $DATA_PATA $LOG_PATA $PCIE_ADDR 0 spandb $BASE_DB_PATH

Note: The TopFS also has a cache, and the cache size is defined as SPDK_MEM_POOL_SIZE in io_spdk.h. Please make sure the hugepages size is bigger than this.

3. Papers

Hao Chen, Chaoyi Ruan, Cheng Li, Xiaosong Ma, Yinlong Xu. SpanDB: A Fast, Cost-Effective LSM-tree Based KV Store on Hybrid Storage. In Proceedings of FAST'21: 19th USENIX Conference on File and Storage Technologies (FAST'2021).

About

A Fast, Cost-Effective LSM-tree Based KV Store on Hybrid Storage

License:GNU General Public License v2.0


Languages

Language:C++ 81.0%Language:Java 11.1%Language:Python 2.1%Language:C 1.9%Language:Perl 1.6%Language:Shell 1.2%Language:CMake 0.4%Language:Makefile 0.3%Language:PowerShell 0.1%Language:Assembly 0.1%Language:PHP 0.1%Language:Ruby 0.0%Language:JavaScript 0.0%Language:Starlark 0.0%Language:Dockerfile 0.0%