From 28f2d3cca6937436358acee2f5dd5dc8da126657 Mon Sep 17 00:00:00 2001 From: Mark Callaghan Date: Wed, 29 Jun 2022 07:22:22 -0700 Subject: [PATCH] Benchmark fix write amplification computation (#10236) Summary: Pull Request resolved: https://github.com/facebook/rocksdb/pull/10236 Reviewed By: ajkr Differential Revision: D37489898 Pulled By: mdcallag fbshipit-source-id: 4b4565973b1f2c47342b4d1b857c8f89e91da145 --- tools/benchmark.sh | 51 +++++++++++++++++++++++++++++++++++++++------- 1 file changed, 44 insertions(+), 7 deletions(-) diff --git a/tools/benchmark.sh b/tools/benchmark.sh index 4e5dae437..e0f252219 100755 --- a/tools/benchmark.sh +++ b/tools/benchmark.sh @@ -466,6 +466,26 @@ function stop_stats { echo -e "max sizes (GB): $am all, $sm sst, $lm log, $bm blob" >> $output.sizes } +function units_as_gb { + size=$1 + units=$2 + + case $units in + MB) + echo "$size" | awk '{ printf "%.1f", $1 / 1024.0 }' + ;; + GB) + echo "$size" + ;; + TB) + echo "$size" | awk '{ printf "%.1f", $1 * 1024.0 }' + ;; + *) + echo "NA" + ;; + esac +} + function summarize_result { test_out=$1 test_name=$2 @@ -498,14 +518,31 @@ function summarize_result { mb_sec=$( grep ^${bench_name} $test_out | awk '{ print $11 }' ) fi - flush_wgb=$( grep "^Flush(GB)" $test_out | tail -1 | awk '{ print $3 }' | tr ',' ' ' | awk '{ print $1 }' ) - sum_wgb=$( grep "^Cumulative compaction" $test_out | tail -1 | awk '{ printf "%.1f", $3 }' ) - cmb_ps=$( grep "^Cumulative compaction" $test_out | tail -1 | awk '{ printf "%.1f", $6 }' ) - if [[ "$sum_wgb" == "" || "$flush_wgb" == "" || "$flush_wgb" == "0.000" ]]; then - wamp="" + # For RocksDB version 4.x there are fewer fields but this still parses correctly + # Cumulative writes: 242M writes, 242M keys, 18M commit groups, 12.9 writes per commit group, ingest: 95.96 GB, 54.69 MB/s + cum_writes_gb_orig=$( grep "^Cumulative writes" "$test_out" | tail -1 | awk '{ for (x=1; x<=NF; x++) { if ($x == "ingest:") { printf "%.1f", $(x+1) } } }' ) + cum_writes_units=$( grep "^Cumulative writes" "$test_out" | tail -1 | awk '{ for (x=1; x<=NF; x++) { if ($x == "ingest:") { print $(x+2) } } }' | sed 's/,//g' ) + cum_writes_gb=$( units_as_gb "$cum_writes_gb_orig" "$cum_writes_units" ) + + # Cumulative compaction: 1159.74 GB write, 661.03 MB/s write, 1108.89 GB read, 632.04 MB/s read, 6284.3 seconds + cmb_ps=$( grep "^Cumulative compaction" "$test_out" | tail -1 | awk '{ printf "%.1f", $6 }' ) + sum_wgb_orig=$( grep "^Cumulative compaction" "$test_out" | tail -1 | awk '{ printf "%.1f", $3 }' ) + sum_wgb_units=$( grep "^Cumulative compaction" "$test_out" | tail -1 | awk '{ print $4 }' ) + sum_wgb=$( units_as_gb "$sum_wgb_orig" "$sum_wgb_units" ) + + # Flush(GB): cumulative 97.193, interval 1.247 + flush_wgb=$( grep "^Flush(GB)" "$test_out" | tail -1 | awk '{ print $3 }' | tr ',' ' ' | awk '{ print $1 }' ) + + if [[ "$sum_wgb" == "NA" || \ + "$cum_writes_gb" == "NA" || \ + "$cum_writes_gb_orig" == "0.0" || \ + -z "$cum_writes_gb_orig" || \ + -z "$flush_wgb" ]]; then + wamp="NA" else - wamp=$( echo "$sum_wgb / $flush_wgb" | bc -l | awk '{ printf "%.1f", $1 }' ) + wamp=$( echo "( $sum_wgb + $flush_wgb ) / $cum_writes_gb" | bc -l | awk '{ printf "%.1f", $1 }' ) fi + c_wsecs=$( grep "^ Sum" $test_out | tail -1 | awk '{ printf "%.0f", $15 }' ) c_csecs=$( grep "^ Sum" $test_out | tail -1 | awk '{ printf "%.0f", $16 }' ) @@ -525,7 +562,7 @@ function summarize_result { u_cpu=$( awk '{ printf "%.1f", $2 / 1000.0 }' $time_out ) s_cpu=$( awk '{ printf "%.1f", $3 / 1000.0 }' $time_out ) - rss="na" + rss="NA" if [ -f $test_out.stats.ps ]; then rss=$( tail -1 $test_out.stats.ps | awk '{ printf "%.1f\n", $6 / (1024 * 1024) }' ) fi