1#!/usr/bin/env bash 2 3testdir=$(readlink -f $(dirname $0)) 4rootdir=$(readlink -f $testdir/../../..) 5source $rootdir/test/common/autotest_common.sh 6 7sanitize_results() { 8 process_core 9 [[ -d $RESULTS_DIR ]] && chmod 644 "$RESULTS_DIR/"* 10} 11 12dump_db_bench_on_err() { 13 # Fetch std dump of the last run_step that might have failed 14 [[ -e $db_bench ]] || return 0 15 16 # Dump entire *.txt to stderr to clearly see what might have failed 17 xtrace_disable 18 mapfile -t step_map < "$db_bench" 19 printf '%s\n' "${step_map[@]/#/* $step (FAILED)}" >&2 20 xtrace_restore 21} 22 23run_step() { 24 if [ -z "$1" ]; then 25 echo run_step called with no parameter 26 exit 1 27 fi 28 29 cat <<- EOL >> "$1"_flags.txt 30 --spdk=$ROCKSDB_CONF 31 --spdk_bdev=Nvme0n1 32 --spdk_cache_size=$CACHE_SIZE 33 EOL 34 35 db_bench=$1_db_bench.txt 36 echo -n Start $1 test phase... 37 time taskset 0xFF $DB_BENCH --flagfile="$1"_flags.txt &> "$db_bench" 38 DB_BENCH_FILE=$(grep -o '/dev/shm/\(\w\|\.\|\d\|/\)*' "$db_bench") 39 gzip $DB_BENCH_FILE 40 mv $DB_BENCH_FILE.gz "$1"_trace.gz 41 chmod 644 "$1"_trace.gz 42 echo done. 43} 44 45run_bsdump() { 46 # 0x80 is the bit mask for BlobFS tracepoints 47 $SPDK_EXAMPLE_DIR/blobcli -j $ROCKSDB_CONF -b Nvme0n1 --tpoint-group-mask 0x80 &> bsdump.txt 48} 49 50# In the autotest job, we copy the rocksdb source to just outside the spdk directory. 51DB_BENCH_DIR="$rootdir/../rocksdb" 52DB_BENCH=$DB_BENCH_DIR/db_bench 53ROCKSDB_CONF=$testdir/rocksdb.json 54 55if [ ! -e $DB_BENCH_DIR ]; then 56 echo $DB_BENCH_DIR does not exist 57 false 58fi 59 60timing_enter db_bench_build 61 62pushd $DB_BENCH_DIR 63if [ -z "$SKIP_GIT_CLEAN" ]; then 64 git clean -x -f -d 65fi 66 67EXTRA_CXXFLAGS="" 68GCC_VERSION=$(cc -dumpversion | cut -d. -f1) 69if ((GCC_VERSION >= 9)); then 70 EXTRA_CXXFLAGS+="-Wno-deprecated-copy -Wno-pessimizing-move -Wno-error=stringop-truncation" 71fi 72 73$MAKE db_bench $MAKEFLAGS $MAKECONFIG DEBUG_LEVEL=0 SPDK_DIR=$rootdir EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS" 74popd 75 76timing_exit db_bench_build 77 78$rootdir/scripts/gen_nvme.sh --json-with-subsystems > $ROCKSDB_CONF 79 80trap 'dump_db_bench_on_err; run_bsdump || :; rm -f $ROCKSDB_CONF; sanitize_results; exit 1' SIGINT SIGTERM EXIT 81 82if [ -z "$SKIP_MKFS" ]; then 83 # 0x80 is the bit mask for BlobFS tracepoints 84 run_test "blobfs_mkfs" $rootdir/test/blobfs/mkfs/mkfs $ROCKSDB_CONF Nvme0n1 --tpoint-group-mask 0x80 85fi 86 87mkdir -p $output_dir/rocksdb 88RESULTS_DIR=$output_dir/rocksdb 89if [ $RUN_NIGHTLY -eq 1 ]; then 90 CACHE_SIZE=4096 91 DURATION=60 92 NUM_KEYS=100000000 93else 94 CACHE_SIZE=2048 95 DURATION=20 96 NUM_KEYS=20000000 97fi 98# Make sure that there's enough memory available for the mempool. Unfortunately, 99# db_bench doesn't seem to allocate memory from all numa nodes since all of it 100# comes exclusively from node0. With that in mind, try to allocate CACHE_SIZE 101# + some_overhead (1G) of pages but only on node0 to make sure that we end up 102# with the right amount not allowing setup.sh to split it by using the global 103# nr_hugepages setting. Instead of bypassing it completely, we use it to also 104# get the right size of hugepages. 105HUGEMEM=$((CACHE_SIZE + 1024)) HUGENODE=0 \ 106 "$rootdir/scripts/setup.sh" 107 108cd $RESULTS_DIR 109cp $testdir/common_flags.txt insert_flags.txt 110cat << EOL >> insert_flags.txt 111--benchmarks=fillseq 112--threads=1 113--disable_wal=1 114--use_existing_db=0 115--num=$NUM_KEYS 116EOL 117 118cp $testdir/common_flags.txt randread_flags.txt 119cat << EOL >> randread_flags.txt 120--benchmarks=readrandom 121--threads=16 122--duration=$DURATION 123--disable_wal=1 124--use_existing_db=1 125--num=$NUM_KEYS 126EOL 127 128cp $testdir/common_flags.txt overwrite_flags.txt 129cat << EOL >> overwrite_flags.txt 130--benchmarks=overwrite 131--threads=1 132--duration=$DURATION 133--disable_wal=1 134--use_existing_db=1 135--num=$NUM_KEYS 136EOL 137 138cp $testdir/common_flags.txt readwrite_flags.txt 139cat << EOL >> readwrite_flags.txt 140--benchmarks=readwhilewriting 141--threads=4 142--duration=$DURATION 143--disable_wal=1 144--use_existing_db=1 145--num=$NUM_KEYS 146EOL 147 148cp $testdir/common_flags.txt writesync_flags.txt 149cat << EOL >> writesync_flags.txt 150--benchmarks=overwrite 151--threads=1 152--duration=$DURATION 153--disable_wal=0 154--use_existing_db=1 155--sync=1 156--num=$NUM_KEYS 157EOL 158 159run_test "rocksdb_insert" run_step insert 160run_test "rocksdb_overwrite" run_step overwrite 161run_test "rocksdb_readwrite" run_step readwrite 162run_test "rocksdb_writesync" run_step writesync 163run_test "rocksdb_randread" run_step randread 164 165trap - SIGINT SIGTERM EXIT 166 167run_bsdump 168rm -f $ROCKSDB_CONF 169sanitize_results 170