summaryrefslogtreecommitdiffstats
path: root/src/spdk/test/blobfs/rocksdb
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 18:24:20 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 18:24:20 +0000
commit483eb2f56657e8e7f419ab1a4fab8dce9ade8609 (patch)
treee5d88d25d870d5dedacb6bbdbe2a966086a0a5cf /src/spdk/test/blobfs/rocksdb
parentInitial commit. (diff)
downloadceph-483eb2f56657e8e7f419ab1a4fab8dce9ade8609.tar.xz
ceph-483eb2f56657e8e7f419ab1a4fab8dce9ade8609.zip
Adding upstream version 14.2.21.upstream/14.2.21upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
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.sh134
-rwxr-xr-xsrc/spdk/test/blobfs/rocksdb/run_tests.sh197
5 files changed, 429 insertions, 0 deletions
diff --git a/src/spdk/test/blobfs/rocksdb/.gitignore b/src/spdk/test/blobfs/rocksdb/.gitignore
new file mode 100644
index 00000000..1a06816d
--- /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 00000000..6390c7a4
--- /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 00000000..1ba8a730
--- /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 00000000..1a73ee55
--- /dev/null
+++ b/src/spdk/test/blobfs/rocksdb/rocksdb.sh
@@ -0,0 +1,134 @@
+#!/usr/bin/env bash
+
+set -ex
+
+run_step() {
+ if [ -z "$1" ]; then
+ echo run_step called with no parameter
+ exit 1
+ fi
+
+ echo "--spdk=$ROCKSDB_CONF" >> "$1"_flags.txt
+ echo "--spdk_bdev=Nvme0n1" >> "$1"_flags.txt
+ echo "--spdk_cache_size=$CACHE_SIZE" >> "$1"_flags.txt
+
+ echo -n Start $1 test phase...
+ /usr/bin/time taskset 0xFF $DB_BENCH --flagfile="$1"_flags.txt &> "$1"_db_bench.txt
+ echo done.
+}
+
+run_bsdump() {
+ $rootdir/examples/blob/cli/blobcli -c $ROCKSDB_CONF -b Nvme0n1 -D &> bsdump.txt
+}
+
+testdir=$(readlink -f $(dirname $0))
+rootdir=$(readlink -f $testdir/../../..)
+source $rootdir/test/common/autotest_common.sh
+
+DB_BENCH_DIR=/usr/src/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, skipping rocksdb tests
+ exit 0
+fi
+
+timing_enter rocksdb
+
+timing_enter db_bench_build
+
+pushd $DB_BENCH_DIR
+git clean -x -f -d
+$MAKE db_bench $MAKEFLAGS $MAKECONFIG DEBUG_LEVEL=0 SPDK_DIR=$rootdir
+popd
+
+timing_exit db_bench_build
+
+$rootdir/scripts/gen_nvme.sh > $ROCKSDB_CONF
+
+trap 'run_bsdump; rm -f $ROCKSDB_CONF; exit 1' SIGINT SIGTERM EXIT
+
+timing_enter mkfs
+$rootdir/test/blobfs/mkfs/mkfs $ROCKSDB_CONF Nvme0n1
+timing_exit mkfs
+
+mkdir $output_dir/rocksdb
+RESULTS_DIR=$output_dir/rocksdb
+CACHE_SIZE=4096
+if [ $RUN_NIGHTLY_FAILING -eq 1 ]; then
+ DURATION=60
+ NUM_KEYS=100000000
+else
+ DURATION=20
+ NUM_KEYS=20000000
+fi
+
+cd $RESULTS_DIR
+cp $testdir/common_flags.txt insert_flags.txt
+echo "--benchmarks=fillseq" >> insert_flags.txt
+echo "--threads=1" >> insert_flags.txt
+echo "--disable_wal=1" >> insert_flags.txt
+echo "--use_existing_db=0" >> insert_flags.txt
+echo "--num=$NUM_KEYS" >> insert_flags.txt
+
+cp $testdir/common_flags.txt randread_flags.txt
+echo "--benchmarks=readrandom" >> randread_flags.txt
+echo "--threads=16" >> randread_flags.txt
+echo "--duration=$DURATION" >> randread_flags.txt
+echo "--disable_wal=1" >> randread_flags.txt
+echo "--use_existing_db=1" >> randread_flags.txt
+echo "--num=$NUM_KEYS" >> randread_flags.txt
+
+cp $testdir/common_flags.txt overwrite_flags.txt
+echo "--benchmarks=overwrite" >> overwrite_flags.txt
+echo "--threads=1" >> overwrite_flags.txt
+echo "--duration=$DURATION" >> overwrite_flags.txt
+echo "--disable_wal=1" >> overwrite_flags.txt
+echo "--use_existing_db=1" >> overwrite_flags.txt
+echo "--num=$NUM_KEYS" >> overwrite_flags.txt
+
+cp $testdir/common_flags.txt readwrite_flags.txt
+echo "--benchmarks=readwhilewriting" >> readwrite_flags.txt
+echo "--threads=4" >> readwrite_flags.txt
+echo "--duration=$DURATION" >> readwrite_flags.txt
+echo "--disable_wal=1" >> readwrite_flags.txt
+echo "--use_existing_db=1" >> readwrite_flags.txt
+echo "--num=$NUM_KEYS" >> readwrite_flags.txt
+
+cp $testdir/common_flags.txt writesync_flags.txt
+echo "--benchmarks=overwrite" >> writesync_flags.txt
+echo "--threads=1" >> writesync_flags.txt
+echo "--duration=$DURATION" >> writesync_flags.txt
+echo "--disable_wal=0" >> writesync_flags.txt
+echo "--use_existing_db=1" >> writesync_flags.txt
+echo "--sync=1" >> writesync_flags.txt
+echo "--num=$NUM_KEYS" >> writesync_flags.txt
+
+timing_enter rocksdb_insert
+run_step insert
+timing_exit rocksdb_insert
+
+timing_enter rocksdb_overwrite
+run_step overwrite
+timing_exit rocksdb_overwrite
+
+timing_enter rocksdb_readwrite
+run_step readwrite
+timing_exit rocksdb_readwrite
+
+timing_enter rocksdb_writesync
+run_step writesync
+timing_exit rocksdb_writesync
+
+timing_enter rocksdb_randread
+run_step randread
+timing_exit rocksdb_randread
+
+trap - SIGINT SIGTERM EXIT
+
+run_bsdump
+rm -f $ROCKSDB_CONF
+
+report_test_completion "blobfs"
+timing_exit rocksdb
diff --git a/src/spdk/test/blobfs/rocksdb/run_tests.sh b/src/spdk/test/blobfs/rocksdb/run_tests.sh
new file mode 100755
index 00000000..d65d3b10
--- /dev/null
+++ b/src/spdk/test/blobfs/rocksdb/run_tests.sh
@@ -0,0 +1,197 @@
+#!/bin/bash
+set -e
+
+if [ $# -eq 0 ]
+then
+ echo "usage: $0 <location of db_bench>"
+ exit 1
+fi
+
+DB_BENCH=$(readlink -f $1)
+[ -e $DB_BENCH ] || (echo "$DB_BENCH does not exist - needs to be built" && exit 1)
+
+hash mkfs.xfs
+: ${USE_PERF:=1}
+if ! hash perf; then
+ USE_PERF=0
+fi
+hash python
+[ -e /usr/include/gflags/gflags.h ] || (echo "gflags not installed." && exit 1)
+
+# Increase max number of file descriptors. This will be inherited
+# by processes spawned from this script.
+ulimit -n 16384
+
+TESTDIR=$(readlink -f $(dirname $0))
+
+if ls $TESTDIR/results/testrun_* &> /dev/null; then
+ mkdir -p $TESTDIR/results/old
+ mv $TESTDIR/results/testrun_* $TESTDIR/results/old
+fi
+
+if [ -z "$RESULTS_DIR" ]; then
+ RESULTS_DIR=$TESTDIR/results/testrun_`date +%Y%m%d_%H%M%S`
+ mkdir -p $RESULTS_DIR
+ rm -f $TESTDIR/results/last
+ ln -s $RESULTS_DIR $TESTDIR/results/last
+fi
+
+: ${CACHE_SIZE:=4096}
+: ${DURATION:=120}
+: ${NUM_KEYS:=500000000}
+: ${ROCKSDB_CONF:=/usr/local/etc/spdk/rocksdb.conf}
+
+if [ "$NO_SPDK" = "1" ]
+then
+ [ -e /dev/nvme0n1 ] || (echo "No /dev/nvme0n1 device node found." && exit 1)
+else
+ [ -e /dev/nvme0n1 ] && (echo "/dev/nvme0n1 device found - need to run SPDK setup.sh script to bind to UIO." && exit 1)
+fi
+
+cd $RESULTS_DIR
+
+SYSINFO_FILE=sysinfo.txt
+COMMAND="hostname"
+echo ">> $COMMAND : " >> $SYSINFO_FILE
+$COMMAND >> $SYSINFO_FILE
+echo >> $SYSINFO_FILE
+
+COMMAND="cat /proc/cpuinfo"
+echo ">> $COMMAND : " >> $SYSINFO_FILE
+$COMMAND >> $SYSINFO_FILE
+echo >> $SYSINFO_FILE
+
+COMMAND="cat /proc/meminfo"
+echo ">> $COMMAND : " >> $SYSINFO_FILE
+$COMMAND >> $SYSINFO_FILE
+echo >> $SYSINFO_FILE
+
+if [ "$NO_SPDK" = "1" ]
+then
+ echo -n Creating and mounting XFS filesystem...
+ sudo mkdir -p /mnt/rocksdb
+ sudo umount /mnt/rocksdb || true &> /dev/null
+ sudo mkfs.xfs -d agcount=32 -l su=4096 -f /dev/nvme0n1 &> mkfs_xfs.txt
+ sudo mount -o discard /dev/nvme0n1 /mnt/rocksdb
+ sudo chown $USER /mnt/rocksdb
+ echo done.
+fi
+
+cp $TESTDIR/common_flags.txt insert_flags.txt
+echo "--benchmarks=fillseq" >> insert_flags.txt
+echo "--threads=1" >> insert_flags.txt
+echo "--disable_wal=1" >> insert_flags.txt
+echo "--use_existing_db=0" >> insert_flags.txt
+echo "--num=$NUM_KEYS" >> insert_flags.txt
+
+cp $TESTDIR/common_flags.txt randread_flags.txt
+echo "--benchmarks=readrandom" >> randread_flags.txt
+echo "--threads=16" >> randread_flags.txt
+echo "--duration=$DURATION" >> randread_flags.txt
+echo "--disable_wal=1" >> randread_flags.txt
+echo "--use_existing_db=1" >> randread_flags.txt
+echo "--num=$NUM_KEYS" >> randread_flags.txt
+
+cp $TESTDIR/common_flags.txt overwrite_flags.txt
+echo "--benchmarks=overwrite" >> overwrite_flags.txt
+echo "--threads=1" >> overwrite_flags.txt
+echo "--duration=$DURATION" >> overwrite_flags.txt
+echo "--disable_wal=1" >> overwrite_flags.txt
+echo "--use_existing_db=1" >> overwrite_flags.txt
+echo "--num=$NUM_KEYS" >> overwrite_flags.txt
+
+cp $TESTDIR/common_flags.txt readwrite_flags.txt
+echo "--benchmarks=readwhilewriting" >> readwrite_flags.txt
+echo "--threads=4" >> readwrite_flags.txt
+echo "--duration=$DURATION" >> readwrite_flags.txt
+echo "--disable_wal=1" >> readwrite_flags.txt
+echo "--use_existing_db=1" >> readwrite_flags.txt
+echo "--num=$NUM_KEYS" >> readwrite_flags.txt
+
+cp $TESTDIR/common_flags.txt writesync_flags.txt
+echo "--benchmarks=overwrite" >> writesync_flags.txt
+echo "--threads=1" >> writesync_flags.txt
+echo "--duration=$DURATION" >> writesync_flags.txt
+echo "--disable_wal=0" >> writesync_flags.txt
+echo "--use_existing_db=1" >> writesync_flags.txt
+echo "--sync=1" >> writesync_flags.txt
+echo "--num=$NUM_KEYS" >> writesync_flags.txt
+
+run_step() {
+ if [ -z "$1" ]
+ then
+ echo run_step called with no parameter
+ exit 1
+ fi
+
+ if [ -z "$NO_SPDK" ]
+ then
+ echo "--spdk=$ROCKSDB_CONF" >> "$1"_flags.txt
+ echo "--spdk_bdev=Nvme0n1" >> "$1"_flags.txt
+ echo "--spdk_cache_size=$CACHE_SIZE" >> "$1"_flags.txt
+ fi
+
+ if [ "$NO_SPDK" = "1" ]
+ then
+ echo "--bytes_per_sync=262144" >> "$1"_flags.txt
+ cat /sys/block/nvme0n1/stat > "$1"_blockdev_stats.txt
+ fi
+
+ echo -n Start $1 test phase...
+ if [ "$USE_PERF" = "1" ]
+ then
+ sudo /usr/bin/time taskset 0xFF perf record $DB_BENCH --flagfile="$1"_flags.txt &> "$1"_db_bench.txt
+ else
+ sudo /usr/bin/time taskset 0xFF $DB_BENCH --flagfile="$1"_flags.txt &> "$1"_db_bench.txt
+ fi
+ echo done.
+
+ if [ "$NO_SPDK" = "1" ]
+ then
+ drop_caches
+ cat /sys/block/nvme0n1/stat >> "$1"_blockdev_stats.txt
+ fi
+
+ if [ "$USE_PERF" = "1" ]
+ then
+ echo -n Generating perf report for $1 test phase...
+ sudo perf report -f -n | sed '/#/d' | sed '/%/!d' | sort -r > $1.perf.txt
+ sudo rm perf.data
+ $TESTDIR/postprocess.py `pwd` $1 > $1_summary.txt
+ echo done.
+ fi
+}
+
+drop_caches() {
+ echo -n Cleaning Page Cache...
+ echo 3 > /proc/sys/vm/drop_caches
+ echo done.
+}
+
+if [ -z "$SKIP_INSERT" ]
+then
+ run_step insert
+fi
+if [ -z "$SKIP_OVERWRITE" ]
+then
+ run_step overwrite
+fi
+if [ -z "$SKIP_READWRITE" ]
+then
+ run_step readwrite
+fi
+if [ -z "$SKIP_WRITESYNC" ]
+then
+ run_step writesync
+fi
+if [ -z "$SKIP_RANDREAD" ]
+then
+ run_step randread
+fi
+
+if [ "$NO_SPDK" = "1" ]
+then
+ echo -n Unmounting XFS filesystem...
+ sudo umount /mnt/rocksdb || true &> /dev/null
+ echo done.
+fi