]> git.proxmox.com Git - ceph.git/blame - ceph/src/rocksdb/tools/run_blob_bench.sh
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / rocksdb / tools / run_blob_bench.sh
CommitLineData
1e59de90
TL
1#!/usr/bin/env bash
2# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
3#
4# BlobDB benchmark script
5#
6# REQUIRES: benchmark.sh is in the tools subdirectory
7#
8# After the execution of this script, log files are available in $output_dir.
9# report.tsv provides high level statistics.
10#
11# Should be run from the parent of the tools directory. The command line is:
12# [$env_vars] tools/run_blob_bench.sh
13#
14# This runs the following sequence of BlobDB performance tests:
15# phase 1) write-only - bulkload+compact, overwrite+waitforcompaction
16# phase 2) read-write - readwhilewriting, fwdrangewhilewriting
17# phase 3) read-only - readrandom, fwdrange
18#
19
20# Exit Codes
21EXIT_INVALID_ARGS=1
22
23# Size constants
24K=1024
25M=$((1024 * K))
26G=$((1024 * M))
27T=$((1024 * G))
28
29function display_usage() {
30 echo "usage: run_blob_bench.sh [--help]"
31 echo ""
32 echo "Runs the following sequence of BlobDB benchmark tests using tools/benchmark.sh:"
33 echo -e "\tPhase 1: write-only tests: bulkload+compact, overwrite+waitforcompaction"
34 echo -e "\tPhase 2: read-write tests: readwhilewriting, fwdrangewhilewriting"
35 echo -e "\tPhase 3: read-only tests: readrandom, fwdrange"
36 echo ""
37 echo "Environment Variables:"
38 echo -e "\tJOB_ID\t\t\t\tIdentifier for the benchmark job, will appear in the results (default: empty)"
39 echo -e "\tDB_DIR\t\t\t\tPath for the RocksDB data directory (mandatory)"
40 echo -e "\tWAL_DIR\t\t\t\tPath for the RocksDB WAL directory (mandatory)"
41 echo -e "\tOUTPUT_DIR\t\t\tPath for the benchmark results (mandatory)"
42 echo -e "\tNUM_THREADS\t\t\tNumber of threads (default: 16)"
43 echo -e "\tCOMPRESSION_TYPE\t\tCompression type for the SST files (default: lz4)"
44 echo -e "\tDB_SIZE\t\t\t\tRaw (uncompressed) database size (default: 1 TB)"
45 echo -e "\tVALUE_SIZE\t\t\tValue size (default: 1 KB)"
46 echo -e "\tNUM_KEYS\t\t\tNumber of keys (default: raw database size divided by value size)"
47 echo -e "\tDURATION\t\t\tIndividual duration for read-write/read-only tests in seconds (default: 1800)"
48 echo -e "\tWRITE_BUFFER_SIZE\t\tWrite buffer (memtable) size (default: 1 GB)"
49 echo -e "\tENABLE_BLOB_FILES\t\tEnable blob files (default: 1)"
50 echo -e "\tMIN_BLOB_SIZE\t\t\tSize threshold for storing values in blob files (default: 0)"
51 echo -e "\tBLOB_FILE_SIZE\t\t\tBlob file size (default: same as write buffer size)"
52 echo -e "\tBLOB_COMPRESSION_TYPE\t\tCompression type for the blob files (default: lz4)"
53 echo -e "\tENABLE_BLOB_GC\t\t\tEnable blob garbage collection (default: 1)"
54 echo -e "\tBLOB_GC_AGE_CUTOFF\t\tBlob garbage collection age cutoff (default: 0.25)"
55 echo -e "\tBLOB_GC_FORCE_THRESHOLD\t\tThreshold for forcing garbage collection of the oldest blob files (default: 1.0)"
56 echo -e "\tBLOB_COMPACTION_READAHEAD_SIZE\tBlob compaction readahead size (default: 0)"
57 echo -e "\tBLOB_FILE_STARTING_LEVEL\t\tBlob file starting level (default: 0)"
58 echo -e "\tUSE_BLOB_CACHE\t\t\tEnable blob cache. (default: 1)"
59 echo -e "\tUSE_SHARED_BLOCK_AND_BLOB_CACHE\t\t\tUse the same backing cache for block cache and blob cache. (default: 1)"
60 echo -e "\tBLOB_CACHE_SIZE\t\t\tSize of the blob cache (default: 16GB)"
61 echo -e "\tBLOB_CACHE_NUMSHARDBITS\t\t\tNumber of shards for the blob cache is 2 ** blob_cache_numshardbits (default: 6)"
62 echo -e "\tPREPOPULATE_BLOB_CACHE\t\t\tPre-populate hot/warm blobs in blob cache (default: 0)"
63 echo -e "\tTARGET_FILE_SIZE_BASE\t\tTarget SST file size for compactions (default: write buffer size, scaled down if blob files are enabled)"
64 echo -e "\tMAX_BYTES_FOR_LEVEL_BASE\tMaximum size for the base level (default: 8 * target SST file size)"
65}
66
67if [ $# -ge 1 ]; then
68 display_usage
69
70 if [ "$1" == "--help" ]; then
71 exit
72 else
73 exit $EXIT_INVALID_ARGS
74 fi
75fi
76
77# shellcheck disable=SC2153
78if [ -z "$DB_DIR" ]; then
79 echo "DB_DIR is not defined"
80 exit $EXIT_INVALID_ARGS
81fi
82
83# shellcheck disable=SC2153
84if [ -z "$WAL_DIR" ]; then
85 echo "WAL_DIR is not defined"
86 exit $EXIT_INVALID_ARGS
87fi
88
89# shellcheck disable=SC2153
90if [ -z "$OUTPUT_DIR" ]; then
91 echo "OUTPUT_DIR is not defined"
92 exit $EXIT_INVALID_ARGS
93fi
94
95# shellcheck disable=SC2153
96job_id=$JOB_ID
97
98db_dir=$DB_DIR
99wal_dir=$WAL_DIR
100output_dir=$OUTPUT_DIR
101
102num_threads=${NUM_THREADS:-16}
103
104compression_type=${COMPRESSION_TYPE:-lz4}
105
106db_size=${DB_SIZE:-$((1 * T))}
107value_size=${VALUE_SIZE:-$((1 * K))}
108num_keys=${NUM_KEYS:-$((db_size / value_size))}
109
110duration=${DURATION:-1800}
111
112write_buffer_size=${WRITE_BUFFER_SIZE:-$((1 * G))}
113
114enable_blob_files=${ENABLE_BLOB_FILES:-1}
115min_blob_size=${MIN_BLOB_SIZE:-0}
116blob_file_size=${BLOB_FILE_SIZE:-$write_buffer_size}
117blob_compression_type=${BLOB_COMPRESSION_TYPE:-lz4}
118enable_blob_garbage_collection=${ENABLE_BLOB_GC:-1}
119blob_garbage_collection_age_cutoff=${BLOB_GC_AGE_CUTOFF:-0.25}
120blob_garbage_collection_force_threshold=${BLOB_GC_FORCE_THRESHOLD:-1.0}
121blob_compaction_readahead_size=${BLOB_COMPACTION_READAHEAD_SIZE:-0}
122blob_file_starting_level=${BLOB_FILE_STARTING_LEVEL:-0}
123use_blob_cache=${USE_BLOB_CACHE:-1}
124use_shared_block_and_blob_cache=${USE_SHARED_BLOCK_AND_BLOB_CACHE:-1}
125blob_cache_size=${BLOB_CACHE_SIZE:-$((16 * G))}
126blob_cache_numshardbits=${BLOB_CACHE_NUMSHARDBITS:-6}
127prepopulate_blob_cache=${PREPOPULATE_BLOB_CACHE:-0}
128
129if [ "$enable_blob_files" == "1" ]; then
130 target_file_size_base=${TARGET_FILE_SIZE_BASE:-$((32 * write_buffer_size / value_size))}
131else
132 target_file_size_base=${TARGET_FILE_SIZE_BASE:-$write_buffer_size}
133fi
134
135max_bytes_for_level_base=${MAX_BYTES_FOR_LEVEL_BASE:-$((8 * target_file_size_base))}
136
137echo "======================== Benchmark setup ========================"
138echo -e "Job ID:\t\t\t\t\t$job_id"
139echo -e "Data directory:\t\t\t\t$db_dir"
140echo -e "WAL directory:\t\t\t\t$wal_dir"
141echo -e "Output directory:\t\t\t$output_dir"
142echo -e "Number of threads:\t\t\t$num_threads"
143echo -e "Compression type for SST files:\t\t$compression_type"
144echo -e "Raw database size:\t\t\t$db_size"
145echo -e "Value size:\t\t\t\t$value_size"
146echo -e "Number of keys:\t\t\t\t$num_keys"
147echo -e "Duration of read-write/read-only tests:\t$duration"
148echo -e "Write buffer size:\t\t\t$write_buffer_size"
149echo -e "Blob files enabled:\t\t\t$enable_blob_files"
150echo -e "Blob size threshold:\t\t\t$min_blob_size"
151echo -e "Blob file size:\t\t\t\t$blob_file_size"
152echo -e "Compression type for blob files:\t$blob_compression_type"
153echo -e "Blob GC enabled:\t\t\t$enable_blob_garbage_collection"
154echo -e "Blob GC age cutoff:\t\t\t$blob_garbage_collection_age_cutoff"
155echo -e "Blob GC force threshold:\t\t$blob_garbage_collection_force_threshold"
156echo -e "Blob compaction readahead size:\t\t$blob_compaction_readahead_size"
157echo -e "Blob file starting level:\t\t$blob_file_starting_level"
158echo -e "Blob cache enabled:\t\t\t$use_blob_cache"
159echo -e "Blob cache and block cache shared:\t\t\t$use_shared_block_and_blob_cache"
160echo -e "Blob cache size:\t\t$blob_cache_size"
161echo -e "Blob cache number of shard bits:\t\t$blob_cache_numshardbits"
162echo -e "Blob cache prepopulated:\t\t\t$prepopulate_blob_cache"
163echo -e "Target SST file size:\t\t\t$target_file_size_base"
164echo -e "Maximum size of base level:\t\t$max_bytes_for_level_base"
165echo "================================================================="
166
167rm -rf "$db_dir"
168rm -rf "$wal_dir"
169rm -rf "$output_dir"
170
171ENV_VARS="\
172 JOB_ID=$job_id \
173 DB_DIR=$db_dir \
174 WAL_DIR=$wal_dir \
175 OUTPUT_DIR=$output_dir \
176 NUM_THREADS=$num_threads \
177 COMPRESSION_TYPE=$compression_type \
178 VALUE_SIZE=$value_size \
179 NUM_KEYS=$num_keys"
180
181ENV_VARS_D="$ENV_VARS DURATION=$duration"
182
183PARAMS="\
184 --enable_blob_files=$enable_blob_files \
185 --min_blob_size=$min_blob_size \
186 --blob_file_size=$blob_file_size \
187 --blob_compression_type=$blob_compression_type \
188 --blob_file_starting_level=$blob_file_starting_level \
189 --use_blob_cache=$use_blob_cache \
190 --use_shared_block_and_blob_cache=$use_shared_block_and_blob_cache \
191 --blob_cache_size=$blob_cache_size \
192 --blob_cache_numshardbits=$blob_cache_numshardbits \
193 --prepopulate_blob_cache=$prepopulate_blob_cache \
194 --write_buffer_size=$write_buffer_size \
195 --target_file_size_base=$target_file_size_base \
196 --max_bytes_for_level_base=$max_bytes_for_level_base"
197
198PARAMS_GC="$PARAMS \
199 --enable_blob_garbage_collection=$enable_blob_garbage_collection \
200 --blob_garbage_collection_age_cutoff=$blob_garbage_collection_age_cutoff \
201 --blob_garbage_collection_force_threshold=$blob_garbage_collection_force_threshold \
202 --blob_compaction_readahead_size=$blob_compaction_readahead_size"
203
204# bulk load (using fillrandom) + compact
205env -u DURATION -S "$ENV_VARS" ./tools/benchmark.sh bulkload "$PARAMS"
206
207# overwrite + waitforcompaction
208env -u DURATION -S "$ENV_VARS" ./tools/benchmark.sh overwrite "$PARAMS_GC"
209
210# readwhilewriting
211env -S "$ENV_VARS_D" ./tools/benchmark.sh readwhilewriting "$PARAMS_GC"
212
213# fwdrangewhilewriting
214env -S "$ENV_VARS_D" ./tools/benchmark.sh fwdrangewhilewriting "$PARAMS_GC"
215
216# readrandom
217env -S "$ENV_VARS_D" ./tools/benchmark.sh readrandom "$PARAMS_GC"
218
219# fwdrange
220env -S "$ENV_VARS_D" ./tools/benchmark.sh fwdrange "$PARAMS_GC"
221
222# save logs to output directory
223cp "$db_dir"/LOG* "$output_dir/"