Skip to content

Commit

Permalink
examples: add ycsb-d simulation example
Browse files Browse the repository at this point in the history
  • Loading branch information
nerdroychan committed Jul 31, 2024
1 parent cc13719 commit 16c6ae7
Show file tree
Hide file tree
Showing 6 changed files with 107 additions and 0 deletions.
48 changes: 48 additions & 0 deletions examples/ycsbd/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
This example shows how to run YCSB-like benchmarks in kvbench by utilizing its customizable
workloads. Here we simulate the YCSB-D workload where there are 5% inserts/writes and 95% reads.
The key distribution still follows Zipfian but the hotspot is always the latest written key.

Unlike YCSB that really inserts a key, kvbench assumes a fixed-sized key space, and a write
operation can be either an insert or an update internally. For the latest key, it should not make
a huge difference as it's usually cached.

The workload file, `ycsbd.toml` is as follows:

```toml
[global]
threads = 1
repeat = 1
klen = 8
vlen = 16
kmin = 0
kmax = 1000000

[[benchmark]]
set_perc = 100
get_perc = 0
del_perc = 0
repeat = 1
dist = "shufflep"
report = "hidden"

[[benchmark]]
timeout = 3
set_perc = 5
get_perc = 95
del_perc = 0
dist = "latest"
report = "finish"
```

In the first phase, all worker threads fill the key space of the store, and the metrics are hidden.
Note that the loading is done using `shufflep` instead of `incrementp`. With `shufflep`, the order
of the keys in the key space is shuffled and each key is written exactly once.
In the second phase, worker threads execute the workload using the built-in `latest` key
distribution.

The script file `run.sh` runs this benchmark against multiple stores with different number of
threads. The number of threads are dynamically adjusted via `global.threads` environment variable.

AMD Ryzen 9 5950X CPU 0-15 results ([pdf](ycsbd.pdf)):

![ycsbd](ycsbd.png)
15 changes: 15 additions & 0 deletions examples/ycsbd/plot.gpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
set terminal pdf
set ylabel "Throughput (MOP/s)"
set xlabel "Threads"
set key left top

set output "ycsbd.pdf"
plot [0:17] [0:] \
"chashmap.txt" using 2:14 with lp ti "chashmap",\
"contrie.txt" using 2:14 with lp ti "contrie",\
"dashmap.txt" using 2:14 with lp ti "dashmap",\
"flurry.txt" using 2:14 with lp ti "flurry",\
"papaya.txt" using 2:14 with lp ti "papaya",\
"scchashmap.txt" using 2:14 with lp ti "scchashmap",\
"mutex_hashmap.txt" using 2:14 with lp ti "mutexhashmap",\
"rwlock_hashmap.txt" using 2:14 with lp ti "rwlockhashmap"
21 changes: 21 additions & 0 deletions examples/ycsbd/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

DIR="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"

cargo +stable build --profile release-lto --all-features

STORE_DIR=$DIR/../../presets/stores
BENCHMARK=$DIR/ycsbd.toml

STORES="chashmap contrie dashmap flurry papaya scchashmap mutex_hashmap rwlock_hashmap"

for s in $STORES; do
echo $s
rm $s.txt 2>/dev/null
for t in `seq 1 16`; do
data="$(env global.threads=$t cargo +stable run --profile release-lto --all-features -- bench -s $STORE_DIR/$s.toml -b $BENCHMARK 2>/dev/null)"
echo "threads $t $data" | tee -a $s.txt
done
done

gnuplot $DIR/plot.gpl
Binary file added examples/ycsbd/ycsbd.pdf
Binary file not shown.
Binary file added examples/ycsbd/ycsbd.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions examples/ycsbd/ycsbd.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[global]
threads = 1
repeat = 1
klen = 8
vlen = 16
kmin = 0
kmax = 1000000

[[benchmark]]
set_perc = 100
get_perc = 0
del_perc = 0
repeat = 1
dist = "shufflep"
report = "hidden"

[[benchmark]]
timeout = 3
set_perc = 5
get_perc = 95
del_perc = 0
dist = "latest"
report = "finish"

0 comments on commit 16c6ae7

Please sign in to comment.