summaryrefslogtreecommitdiffstats
path: root/src/spdk/test/blobfs/rocksdb
diff options
context:
space:
mode:
Diffstat (limited to 'src/spdk/test/blobfs/rocksdb')
-rw-r--r--src/spdk/test/blobfs/rocksdb/.gitignore1
-rw-r--r--src/spdk/test/blobfs/rocksdb/common_flags.txt27
-rwxr-xr-xsrc/spdk/test/blobfs/rocksdb/postprocess.py70
-rwxr-xr-xsrc/spdk/test/blobfs/rocksdb/rocksdb.sh155
-rw-r--r--src/spdk/test/blobfs/rocksdb/rocksdb_commit_id1
5 files changed, 254 insertions, 0 deletions
diff --git a/src/spdk/test/blobfs/rocksdb/.gitignore b/src/spdk/test/blobfs/rocksdb/.gitignore
new file mode 100644
index 000000000..1a06816d8
--- /dev/null
+++ b/src/spdk/test/blobfs/rocksdb/.gitignore
@@ -0,0 +1 @@
+results
diff --git a/src/spdk/test/blobfs/rocksdb/common_flags.txt b/src/spdk/test/blobfs/rocksdb/common_flags.txt
new file mode 100644
index 000000000..6390c7a40
--- /dev/null
+++ b/src/spdk/test/blobfs/rocksdb/common_flags.txt
@@ -0,0 +1,27 @@
+--disable_seek_compaction=1
+--mmap_read=0
+--statistics=1
+--histogram=1
+--key_size=16
+--value_size=1000
+--block_size=4096
+--cache_size=0
+--bloom_bits=10
+--cache_numshardbits=4
+--open_files=500000
+--verify_checksum=1
+--db=/mnt/rocksdb
+--sync=0
+--compression_type=none
+--stats_interval=1000000
+--compression_ratio=1
+--disable_data_sync=0
+--target_file_size_base=67108864
+--max_write_buffer_number=3
+--max_bytes_for_level_multiplier=10
+--max_background_compactions=10
+--num_levels=10
+--delete_obsolete_files_period_micros=3000000
+--max_grandparent_overlap_factor=10
+--stats_per_interval=1
+--max_bytes_for_level_base=10485760
diff --git a/src/spdk/test/blobfs/rocksdb/postprocess.py b/src/spdk/test/blobfs/rocksdb/postprocess.py
new file mode 100755
index 000000000..1ba8a7302
--- /dev/null
+++ b/src/spdk/test/blobfs/rocksdb/postprocess.py
@@ -0,0 +1,70 @@
+#!/usr/bin/env python3
+from collections import namedtuple
+from itertools import islice
+import operator
+import sys
+
+total_samples = 0
+thread_module_samples = {}
+function_module_samples = {}
+module_samples = {}
+threads = set()
+
+ThreadModule = namedtuple('ThreadModule', ['thread', 'module'])
+FunctionModule = namedtuple('FunctionModule', ['function', 'module'])
+
+with open(sys.argv[1] + "/" + sys.argv[2] + ".perf.txt") as f:
+ for line in f:
+ fields = line.split()
+ total_samples += int(fields[1])
+ key = ThreadModule(fields[2], fields[3])
+ thread_module_samples.setdefault(key, 0)
+ thread_module_samples[key] += int(fields[1])
+ key = FunctionModule(fields[5], fields[3])
+ function_module_samples.setdefault(key, 0)
+ function_module_samples[key] += int(fields[1])
+ threads.add(fields[2])
+
+ key = fields[3]
+ module_samples.setdefault(key, 0)
+ module_samples[key] += int(fields[1])
+
+for thread in sorted(threads):
+ thread_pct = 0
+ print("")
+ print("Thread: {:s}".format(thread))
+ print(" Percent Module")
+ print("============================")
+ for key, value in sorted(list(thread_module_samples.items()), key=operator.itemgetter(1), reverse=True):
+ if key.thread == thread:
+ print("{:8.4f} {:20s}".format(float(value) * 100 / total_samples, key.module))
+ thread_pct += float(value) * 100 / total_samples
+ print("============================")
+ print("{:8.4f} Total".format(thread_pct))
+
+print("")
+print(" Percent Module Function")
+print("=================================================================")
+for key, value in islice(sorted(list(function_module_samples.items()), key=operator.itemgetter(1), reverse=True), 100):
+ print(("{:8.4f} {:20s} {:s}".format(float(value) * 100 / total_samples, key.module, key.function)))
+
+print("")
+print("")
+print(" Percent Module")
+print("=================================")
+for key, value in sorted(list(module_samples.items()), key=operator.itemgetter(1), reverse=True):
+ print("{:8.4f} {:s}".format(float(value) * 100 / total_samples, key))
+
+print("")
+with open(sys.argv[1] + "/" + sys.argv[2] + "_db_bench.txt") as f:
+ for line in f:
+ if "maxresident" in line:
+ fields = line.split()
+ print("Wall time elapsed: {:s}".format(fields[2].split("e")[0]))
+ print("CPU utilization: {:s}".format(fields[3].split('C')[0]))
+ user = float(fields[0].split('u')[0])
+ system = float(fields[1].split('s')[0])
+ print("User: {:8.2f} ({:5.2f}%)".format(user, user * 100 / (user + system)))
+ print("System: {:8.2f} ({:5.2f}%)".format(system, system * 100 / (user + system)))
+
+print("")
diff --git a/src/spdk/test/blobfs/rocksdb/rocksdb.sh b/src/spdk/test/blobfs/rocksdb/rocksdb.sh
new file mode 100755
index 000000000..406156905
--- /dev/null
+++ b/src/spdk/test/blobfs/rocksdb/rocksdb.sh
@@ -0,0 +1,155 @@
+#!/usr/bin/env bash
+
+testdir=$(readlink -f $(dirname $0))
+rootdir=$(readlink -f $testdir/../../..)
+source $rootdir/test/common/autotest_common.sh
+
+dump_db_bench_on_err() {
+ # Fetch std dump of the last run_step that might have failed
+ [[ -e $db_bench ]] || return 0
+
+ # Dump entire *.txt to stderr to clearly see what might have failed
+ xtrace_disable
+ mapfile -t step_map < "$db_bench"
+ printf '%s\n' "${step_map[@]/#/* $step (FAILED)}" >&2
+ xtrace_restore
+}
+
+run_step() {
+ if [ -z "$1" ]; then
+ echo run_step called with no parameter
+ exit 1
+ fi
+
+ cat <<- EOL >> "$1"_flags.txt
+ --spdk=$ROCKSDB_CONF
+ --spdk_bdev=Nvme0n1
+ --spdk_cache_size=$CACHE_SIZE
+ EOL
+
+ db_bench=$1_db_bench.txt
+ echo -n Start $1 test phase...
+ time taskset 0xFF $DB_BENCH --flagfile="$1"_flags.txt &> "$db_bench"
+ DB_BENCH_FILE=$(grep -o '/dev/shm/\(\w\|\.\|\d\|/\)*' "$db_bench")
+ gzip $DB_BENCH_FILE
+ mv $DB_BENCH_FILE.gz "$1"_trace.gz
+ chmod 644 "$1"_trace.gz
+ echo done.
+}
+
+run_bsdump() {
+ $SPDK_EXAMPLE_DIR/blobcli -c $ROCKSDB_CONF -b Nvme0n1 -D &> bsdump.txt
+}
+
+# In the autotest job, we copy the rocksdb source to just outside the spdk directory.
+DB_BENCH_DIR="$rootdir/../rocksdb"
+DB_BENCH=$DB_BENCH_DIR/db_bench
+ROCKSDB_CONF=$testdir/rocksdb.conf
+
+if [ ! -e $DB_BENCH_DIR ]; then
+ echo $DB_BENCH_DIR does not exist
+ false
+fi
+
+timing_enter db_bench_build
+
+pushd $DB_BENCH_DIR
+if [ -z "$SKIP_GIT_CLEAN" ]; then
+ git clean -x -f -d
+fi
+
+EXTRA_CXXFLAGS=""
+GCC_VERSION=$(cc -dumpversion | cut -d. -f1)
+if ((GCC_VERSION >= 9)); then
+ EXTRA_CXXFLAGS+="-Wno-deprecated-copy -Wno-pessimizing-move -Wno-error=stringop-truncation"
+fi
+
+$MAKE db_bench $MAKEFLAGS $MAKECONFIG DEBUG_LEVEL=0 SPDK_DIR=$rootdir EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS"
+popd
+
+timing_exit db_bench_build
+
+$rootdir/scripts/gen_nvme.sh > $ROCKSDB_CONF
+# 0x80 is the bit mask for BlobFS tracepoints
+echo "[Global]" >> $ROCKSDB_CONF
+echo "TpointGroupMask 0x80" >> $ROCKSDB_CONF
+
+trap 'dump_db_bench_on_err; run_bsdump || :; rm -f $ROCKSDB_CONF; exit 1' SIGINT SIGTERM EXIT
+
+if [ -z "$SKIP_MKFS" ]; then
+ run_test "blobfs_mkfs" $rootdir/test/blobfs/mkfs/mkfs $ROCKSDB_CONF Nvme0n1
+fi
+
+mkdir -p $output_dir/rocksdb
+RESULTS_DIR=$output_dir/rocksdb
+if [ $RUN_NIGHTLY -eq 1 ]; then
+ CACHE_SIZE=4096
+ DURATION=60
+ NUM_KEYS=100000000
+else
+ CACHE_SIZE=2048
+ DURATION=20
+ NUM_KEYS=20000000
+fi
+
+cd $RESULTS_DIR
+cp $testdir/common_flags.txt insert_flags.txt
+cat << EOL >> insert_flags.txt
+--benchmarks=fillseq
+--threads=1
+--disable_wal=1
+--use_existing_db=0
+--num=$NUM_KEYS
+EOL
+
+cp $testdir/common_flags.txt randread_flags.txt
+cat << EOL >> randread_flags.txt
+--benchmarks=readrandom
+--threads=16
+--duration=$DURATION
+--disable_wal=1
+--use_existing_db=1
+--num=$NUM_KEYS
+EOL
+
+cp $testdir/common_flags.txt overwrite_flags.txt
+cat << EOL >> overwrite_flags.txt
+--benchmarks=overwrite
+--threads=1
+--duration=$DURATION
+--disable_wal=1
+--use_existing_db=1
+--num=$NUM_KEYS
+EOL
+
+cp $testdir/common_flags.txt readwrite_flags.txt
+cat << EOL >> readwrite_flags.txt
+--benchmarks=readwhilewriting
+--threads=4
+--duration=$DURATION
+--disable_wal=1
+--use_existing_db=1
+--num=$NUM_KEYS
+EOL
+
+cp $testdir/common_flags.txt writesync_flags.txt
+cat << EOL >> writesync_flags.txt
+--benchmarks=overwrite
+--threads=1
+--duration=$DURATION
+--disable_wal=0
+--use_existing_db=1
+--sync=1
+--num=$NUM_KEYS
+EOL
+
+run_test "rocksdb_insert" run_step insert
+run_test "rocksdb_overwrite" run_step overwrite
+run_test "rocksdb_readwrite" run_step readwrite
+run_test "rocksdb_writesync" run_step writesync
+run_test "rocksdb_randread" run_step randread
+
+trap - SIGINT SIGTERM EXIT
+
+run_bsdump
+rm -f $ROCKSDB_CONF
diff --git a/src/spdk/test/blobfs/rocksdb/rocksdb_commit_id b/src/spdk/test/blobfs/rocksdb/rocksdb_commit_id
new file mode 100644
index 000000000..efac5a55d
--- /dev/null
+++ b/src/spdk/test/blobfs/rocksdb/rocksdb_commit_id
@@ -0,0 +1 @@
+526c73bd94150cc8fbd651f736e1ca95f50d8e13