Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,9 @@ tags
compile_commands.json
.clangd/
.cache/

CMakeFiles/
CMakeCache.txt
*.cmake

build/
9 changes: 9 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
[submodule "HdrHistogram_c"]
path = HdrHistogram_c
url = https://github.com/HdrHistogram/HdrHistogram_c.git
[submodule "unqlite/unqlite"]
path = unqlite/unqlite
url = https://github.com/symisc/unqlite
[submodule "terarkdb/terarkdb"]
path = terarkdb/terarkdb
url = https://github.com/bytedance/terarkdb.git
[submodule "speedb/speedb"]
path = speedb/speedb
url = https://github.com/speedb-io/speedb
46 changes: 44 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
cmake_minimum_required(VERSION 3.10)
project(ycsb-cpp LANGUAGES C CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

set(CMAKE_BUILD_TYPE Release)
set(CompilerFlags
Expand All @@ -25,6 +26,8 @@ option(BIND_ROCKSDB "build with rocksdb" OFF)
option(BIND_LMDB "build with lmdb" OFF)
option(BIND_LEVELDB "build with leveldb" OFF)
option(BIND_WIREDTIGER "build with wiredtiger" OFF)
option(BIND_UNQLITE "build with unqlite" OFF)
option(BIND_TERARKDB "build with terarkdb" OFF)

option(WITH_ZLIB "linking YCSB with zlib; needed by HdrHISTOGRAM, DO NOT TURN OFF" ON)
option(WITH_LZ4 "linking YCSB with lz4" OFF)
Expand All @@ -48,7 +51,7 @@ if (BIND_ROCKSDB)

find_package(RocksDB CONFIG)
if(RocksDB_FOUND)
target_link_libraries(ycsb PRIVATE RocksDB::rocksdb rpcrt4.lib)
target_link_libraries(ycsb PRIVATE RocksDB::rocksdb)
else()
message(STATUS "Try to find rocksdb library using find_library")
find_library(ROCKSDB_LIB rocksdb REQUIRED)
Expand Down Expand Up @@ -194,8 +197,47 @@ else()
message(STATUS "WITH_BZ2 - OFF")
endif()

if (BIND_UNQLITE)
message(STATUS "BIND_UNQLITE - ON")
file(GLOB_RECURSE YCSB_UNQLITE_SRC "unqlite/*.cc")
target_sources(ycsb PRIVATE ${YCSB_UNQLITE_SRC})
file(GLOB_RECURSE YCSB_UNQLITE_LIB "unqlite/unqlite/unqlite.c")
target_sources(ycsb PRIVATE ${YCSB_UNQLITE_LIB})
else()
message(STATUS "BIND_UNQLITE - OFF")
endif()

if (BIND_TERARKDB)
message(STATUS "BIND_TERARKDB - ON")

file(GLOB YCSB_TERARKDB_SRC "terarkdb/*.cc")
target_sources(ycsb PRIVATE ${YCSB_TERARKDB_SRC})

target_link_libraries(ycsb PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/terarkdb/terarkdb/build/build/lib/libterarkdb.a")
target_include_directories(ycsb PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/terarkdb/terarkdb/build/build/include")

# link all of terarkdb's dependencies
set(TERARKDB_BUILD_DIR "${CMAKE_CURRENT_SOURCE_DIR}/terarkdb/terarkdb/build")
set(TERARKDB_LIB_DEPS_DIR "${TERARKDB_BUILD_DIR}/lib")
find_library(BZ2_LIB bz2 HINTS ${TERARKDB_LIB_DEPS_DIR} REQUIRED)
target_link_libraries(ycsb PRIVATE ${BZ2_LIB})
find_library(LZ4_LIB lz4 HINTS ${TERARKDB_LIB_DEPS_DIR} REQUIRED)
target_link_libraries(ycsb PRIVATE ${LZ4_LIB})
find_library(ZSTD_LIB zstd HINTS ${TERARKDB_LIB_DEPS_DIR} REQUIRED)
target_link_libraries(ycsb PRIVATE ${ZSTD_LIB})
find_library(JEMALLOC_LIB jemalloc HINTS ${TERARKDB_LIB_DEPS_DIR} REQUIRED)
target_link_libraries(ycsb PRIVATE ${JEMALLOC_LIB})
find_library(SNAPPY_LIB snappy HINTS ${TERARKDB_LIB_DEPS_DIR} REQUIRED)
target_link_libraries(ycsb PRIVATE ${SNAPPY_LIB})
find_library(Z_LIB z HINTS ${TERARKDB_LIB_DEPS_DIR} REQUIRED)
target_link_libraries(ycsb PRIVATE ${Z_LIB})
target_include_directories(ycsb PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/terarkdb/terarkdb/build/include")
else()
message(STATUS "BIND_TERARKDB - OFF")
endif()

add_subdirectory(HdrHistogram_c)
include_directories(HdrHistogram_c/include)
add_compile_definitions(HDRMEASUREMENT)
add_dependencies(ycsb hdr_histogram_static)
target_link_libraries(ycsb PRIVATE hdr_histogram_static)
target_link_libraries(ycsb PRIVATE hdr_histogram_static)
56 changes: 56 additions & 0 deletions PROJECT_README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Exposing the “Bleeding-Edge” of Modern Embedded Key-Value Databases

- **CS 6400 DB Project (Group 8)**
- _Members: Richard So, Nandha Sundaravadivel, Drumil Deliwala, Saatvik Agrawal_

## Results

## Setup / Instructions

### Prerequisites

- AWS EC2 Instance, `t2.micro` (although any instance should work)

- Amazon Linux 2 AMI (or any Linux distro)

- Install the following:

- `cmake`, `make`, `gcc`, `g++`
- Install `zlib-devel` or equivalent for compiling `YCSB-cpp`
- `java` (8+) and `maven` (>= 3); using `sdkman` is recommended
- `python3` for running `YCSB`

### Running YCSB (Java) benchmarks

> **Implemented bindings: `xodus`, `mapdb`, `halodb`**

Below is an example of running the `mapdb` binding:

```sh
cd YCSB
./bin/ycsb.sh load mapdb -s -P workloads/workloada
./bin/ycsb.sh run mapdb -s -P workloads/workloada
```

Rinse and repeat for the other bindings.

### Running YCSB-cpp (C++) benchmarks

> **Impmeneted bindings: `unqlite`, `terarkdb`**

Below is an example of compiling and running the `unqlite` binding:

```sh
cd YCSB-cpp
mkdir build && cd build
cmake -DBIND_UNQLITE=1 ..
make clean && make
./ycsb -load -db unqlite -P ../workloads/workloada -s
./ycsb -run -db unqlite -P ../workloads/workloada -s
```

There are additional instructions in the `YCSB-cpp` directory for `terarkdb`,
`leveldb`, and `rocksdb`.

**It is recommended to only bind ONE database at a time when compiling w/
cmake to avoid conflicts.**
85 changes: 76 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,80 @@ This is a fork of [YCSB-C](https://github.com/basicthinker/YCSB-C) with some add
* Modified the workload more similar to the original YCSB
* Supported databases: LevelDB, RocksDB, LMDB, WiredTiger, SQLite

> **Additionally, this repository is an extension of the original
[YCSB-cpp](https://github.com/ls4154/YCSB-cpp) project, now supporting a few
more databases (e.g. Speedb, TerarkDB, UnQLite, etc.) and including instructions
to build and install DBs from source (locally, without root).**
>
> _**This specific fork serves as a portion of an end-of-semester project for
Georgia Tech's CS 6400 Databases course**_

# Build YCSB-cpp

## Prerequisites

* Clone this repository, recursing to all submodules
```sh
git clone --recurse-submodules git@github.com:richardso21/YCSB-cpp.git
```

* Ensure you have `gcc` and `cmake` installed

### Installing LevelDB

* LevelDB is included as a submodule in this repository. To build it, run the following commands:
```sh
cd YCSB-cpp/third-party/leveldb
mkdir build && cd build

# to install globally...
cmake -DCMAKE_BUILD_TYPE=Release ..

# or, to install locally (e.g. if you are on PACE)
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=~/.local ..

make install
```

* **If you installed locally**, you will need to add the following to your
`.bashrc` or `.bash_profile` (or `zsh` equivalents):
```bash
export PATH=$PATH:~/.local/bin
export CPATH=$CPATH:~/.local/include
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:~/.local/lib
```
> _LevelDB is included in order to provide a reference point for the original
`YCSB` implementation in Java._

### Building TerarkDB

* TerarkDB is included as a submodule, found within `YCSB-cpp/terarkdb/terarkdb`.

* **IMPORTANT**: If you are on PACE, or you do not have XSL (or you do not know what it is),
you will need to modify `terarkdb/terarkdb/third-party/CMakeLists.txt` at line 203. Change
the line from:
```cmake
INSTALL_COMMAND $(MAKE) install PREFIX=${CMAKE_BINARY_DIR}
```
to:
```cmake
INSTALL_COMMAND $(MAKE) install_bin install_include install_lib PREFIX=${CMAKE_BINARY_DIR}
```

* To build TerarkDB as a static library for YCSB-cpp, run the following commands:
```sh
cd YCSB-cpp/terarkdb/terarkdb
WITH_TESTS=OFF WITH_ZNS=OFF ./build.sh
```

> **NOTE**: TerarkDB is a fork of RocksDB, and thus shares the same header paths.
**Do not compile YCSB-cpp with both TerarkDB and RocksDB binded simultaneously!**

## Build with Makefile on POSIX

Initialize submodule and use `make` to build.

```
```sh
git clone https://github.com/ls4154/YCSB-cpp.git
cd YCSB-cpp
git submodule update --init
Expand All @@ -23,20 +90,20 @@ make
Databases to bind must be specified as build options. You may also need to add additional link flags (e.g., `-lsnappy`).

To bind LevelDB:
```
```sh
make BIND_LEVELDB=1
```

To build with additional libraries and include directories:
```
```sh
make BIND_LEVELDB=1 EXTRA_CXXFLAGS=-I/example/leveldb/include \
EXTRA_LDFLAGS="-L/example/leveldb/build -lsnappy"
```

Or modify config section in `Makefile`.

RocksDB build example:
```
```sh
EXTRA_CXXFLAGS ?= -I/example/rocksdb/include
EXTRA_LDFLAGS ?= -L/example/rocksdb -ldl -lz -lsnappy -lzstd -lbz2 -llz4

Expand All @@ -45,7 +112,7 @@ BIND_ROCKSDB ?= 1

## Build with CMake on POSIX

```shell
```sh
git submodule update --init
mkdir build
cd build
Expand All @@ -60,22 +127,22 @@ see [BUILD_ON_WINDOWS](BUILD_ON_WINDOWS.md)
## Running

Load data with leveldb:
```
```sh
./ycsb -load -db leveldb -P workloads/workloada -P leveldb/leveldb.properties -s
```

Run workload A with leveldb:
```
```sh
./ycsb -run -db leveldb -P workloads/workloada -P leveldb/leveldb.properties -s
```

Load and run workload B with rocksdb:
```
```sh
./ycsb -load -run -db rocksdb -P workloads/workloadb -P rocksdb/rocksdb.properties -s
```

Pass additional properties:
```
```sh
./ycsb -load -db leveldb -P workloads/workloadb -P rocksdb/rocksdb.properties \
-p threadcount=4 -p recordcount=10000000 -p leveldb.cache_size=134217728 -s
```
Loading