Whamcloud - gitweb
LU-14139 statahead: add test for batch statahead processing 20/41220/22
authorQian Yingjin <qian@ddn.com>
Thu, 14 Jan 2021 08:07:24 +0000 (16:07 +0800)
committerOleg Drokin <green@whamcloud.com>
Sat, 22 Apr 2023 18:31:46 +0000 (18:31 +0000)
This patch adds sanity test_123ad() for batched statahead
processing, verify it work as expected.

Test-Parameters: trivial testlist=sanity env=ONLY=123ad,ONLY_REPEAT=50
Signed-off-by: Qian Yingjin <qian@ddn.com>
Change-Id: I742dcac7140ad842fff2afadeb2d948661365b95
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/41220
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Mikhail Pershin <mpershin@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/tests/sanity.sh

index 62d32ba..f89263d 100755 (executable)
@@ -13703,6 +13703,83 @@ test_123ac() {
 }
 run_test 123ac "verify statahead work by using statx without glimpse RPCs"
 
+test_batch_statahead() {
+       local max=$1
+       local batch_max=$2
+       local num=10000
+       local batch_rpcs
+       local unbatch_rpcs
+       local hit_total
+
+       echo -e "\nbatching: statahead_max=$max statahead_batch_max=$batch_max"
+       $LCTL set_param mdc.*.batch_stats=0
+       $LCTL set_param llite.*.statahead_max=$max
+       $LCTL set_param llite.*.statahead_batch_max=$batch_max
+       # Verify that batched statahead is faster than one without statahead
+       test_123a_base "ls -l"
+
+       stack_trap "rm -rf $DIR/$tdir" EXIT
+       mkdir $DIR/$tdir || error "failed to mkdir $DIR/$tdir"
+       createmany -o $DIR/$tdir/$tfile $num || error "failed to create files"
+
+       # unbatched statahead
+       $LCTL set_param llite.*.statahead_batch_max=0
+       $LCTL set_param llite.*.statahead_stats=clear
+       $LCTL set_param mdc.*.stats=clear
+       cancel_lru_locks mdc
+       cancel_lru_locks osc
+       time ls -l $DIR/$tdir | wc -l
+       unbatch_rpcs=$(calc_stats mdc.*.stats ldlm_ibits_enqueue)
+       sleep 2
+       hit_total=$($LCTL get_param -n llite.*.statahead_stats |
+                   awk '/hit.total:/ { print $NF }')
+       # hit ratio should be larger than 75% (7500).
+       (( $hit_total > 7500 )) ||
+               error "unbatched statahead hit count ($hit_total) is too low"
+
+       # batched statahead
+       $LCTL set_param llite.*.statahead_batch_max=$batch_max
+       $LCTL set_param llite.*.statahead_stats=clear
+       $LCTL set_param mdc.*.batch_stats=clear
+       $LCTL set_param mdc.*.stats=clear
+       cancel_lru_locks mdc
+       cancel_lru_locks osc
+       time ls -l $DIR/$tdir | wc -l
+       batch_rpcs=$(calc_stats mdc.*.stats mds_batch)
+       # wait for statahead thread to quit and update statahead stats
+       sleep 2
+       hit_total=$($LCTL get_param -n llite.*.statahead_stats |
+                   awk '/hit.total:/ { print $NF }')
+       # hit ratio should be larger than 75% (7500).
+       (( $hit_total > 7500 )) ||
+               error "batched statahead hit count ($hit_total) is too low"
+
+       echo "unbatched RPCs: $unbatch_rpcs, batched RPCs: $batch_rpcs"
+       (( $unbatch_rpcs > $batch_rpcs )) ||
+               error "batched statahead does not reduce RPC count"
+       $LCTL get_param mdc.*.batch_stats
+}
+
+test_123ad() {
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
+       (( $MDS1_VERSION >= $(version_code 2.15.53) )) ||
+               skip "Need server version at least 2.15.53"
+
+       local max
+       local batch_max
+
+       max=$($LCTL get_param -n llite.*.statahead_max | head -n 1)
+       batch_max=$($LCTL get_param -n llite.*.statahead_batch_max | head -n 1)
+
+       stack_trap "$LCTL set_param llite.*.statahead_max=$max" EXIT
+       stack_trap "$LCTL set_param llite.*.statahead_batch_max=$batch_max" EXIT
+
+       test_batch_statahead 32 32
+       test_batch_statahead 2048 256
+}
+run_test 123ad "Verify batching statahead works correctly"
+
 test_123b () { # statahead(bug 15027)
        [ $PARALLEL == "yes" ] && skip "skip parallel run"