From cd1e7bdd903ada4467064eaf8613ec62a358fa1c Mon Sep 17 00:00:00 2001 From: Qian Yingjin Date: Thu, 14 Jan 2021 16:07:24 +0800 Subject: [PATCH] LU-14139 statahead: add test for batch statahead processing 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 Change-Id: I742dcac7140ad842fff2afadeb2d948661365b95 Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/41220 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Mikhail Pershin Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin --- lustre/tests/sanity.sh | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index 62d32ba..f89263d 100755 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -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" -- 1.8.3.1