db_bench

db_bench is the main tool that is used to benchmark RocksDB’s performance. RocksDB inherited db_bench from LevelDB, and enhanced it to support many additional options. db_bench supports many benchmarks to generate different types of workloads, and its various options can be used to control the tests.

If you are just getting started with db_bench, here are a few things you can try:

  1. Start with a simple benchmark like fillseq (or fillrandom) to create a database and fill it with some data
  1. ./db_bench --benchmarks="fillseq"

If you want more stats, add the meta operator “stats” and —statistics flag.

  1. ./db_bench --benchmarks="fillseq,stats" --statistics
  1. Read the data back
  1. ./db_bench --benchmarks="readrandom" --use_existing_db

You can also combine multiple benchmarks to the string that is passed to --benchmarks so that they run sequentially. Example:

  1. ./db_bench --benchmarks="fillseq,readrandom,readseq"

More in-depth example of db_bench usage can be found here and here.

Benchmarks List:

  1. fillseq -- write N values in sequential key order in async mode
  2. fillseqdeterministic -- write N values in the specified key order and keep the shape of the LSM tree
  3. fillrandom -- write N values in random key order in async mode
  4. filluniquerandomdeterministic -- write N values in a random key order and keep the shape of the LSM tree
  5. overwrite -- overwrite N values in random key order in async mode
  6. fillsync -- write N/100 values in random key order in sync mode
  7. fill100K -- write N/1000 100K values in random order in async mode
  8. deleteseq -- delete N keys in sequential order
  9. deleterandom -- delete N keys in random order
  10. readseq -- read N times sequentially
  11. readtocache -- 1 thread reading database sequentially
  12. readreverse -- read N times in reverse order
  13. readrandom -- read N times in random order
  14. readmissing -- read N missing keys in random order
  15. readwhilewriting -- 1 writer, N threads doing random reads
  16. readwhilemerging -- 1 merger, N threads doing random reads
  17. readrandomwriterandom -- N threads doing random-read, random-write
  18. prefixscanrandom -- prefix scan N times in random order
  19. updaterandom -- N threads doing read-modify-write for random keys
  20. appendrandom -- N threads doing read-modify-write with growing values
  21. mergerandom -- same as updaterandom/appendrandom using merge operator. Must be used with merge_operator
  22. readrandommergerandom -- perform N random read-or-merge operations. Must be used with merge_operator
  23. newiterator -- repeated iterator creation
  24. seekrandom -- N random seeks, call Next seek_nexts times per seek
  25. seekrandomwhilewriting -- seekrandom and 1 thread doing overwrite
  26. seekrandomwhilemerging -- seekrandom and 1 thread doing merge
  27. crc32c -- repeated crc32c of 4K of data
  28. xxhash -- repeated xxHash of 4K of data
  29. acquireload -- load N*1000 times
  30. fillseekseq -- write N values in sequential key, then read them by seeking to each key
  31. randomtransaction -- execute N random transactions and verify correctness
  32. randomreplacekeys -- randomly replaces N keys by deleting the old version and putting the new version
  33. timeseries -- 1 writer generates time series data and multiple readers doing random reads on id

For a list of all options:

  1. $ ./db_bench -help

persistent_cache_bench

  1. $ ./persistent_cache_bench -help
  2. persistent_cache_bench:
  3. USAGE:
  4. ./persistent_cache_bench [OPTIONS]...
  5. ...
  6. Flags from utilities/persistent_cache/persistent_cache_bench.cc:
  7. -benchmark (Benchmark mode) type: bool default: false
  8. -cache_size (Cache size) type: uint64 default: 18446744073709551615
  9. -cache_type (Cache type. (block_cache, volatile, tiered)) type: string
  10. default: "block_cache"
  11. -enable_pipelined_writes (Enable async writes) type: bool default: false
  12. -iosize (Read IO size) type: int32 default: 4096
  13. -log_path (Path for the log file) type: string default: "/tmp/log"
  14. -nsec (nsec) type: int32 default: 10
  15. -nthread_read (Lookup threads) type: int32 default: 1
  16. -nthread_write (Insert threads) type: int32 default: 1
  17. -path (Path for cachefile) type: string default: "/tmp/microbench/blkcache"
  18. -volatile_cache_pct (Percentage of cache in memory tier.) type: int32
  19. default: 10
  20. -writer_iosize (File writer IO size) type: int32 default: 4096
  21. -writer_qdepth (File writer qdepth) type: int32 default: 1