aboutsummaryrefslogtreecommitdiff
path: root/sys/contrib/openzfs/tests/zfs-tests/tests/perf/perf.shlib
diff options
context:
space:
mode:
Diffstat (limited to 'sys/contrib/openzfs/tests/zfs-tests/tests/perf/perf.shlib')
-rw-r--r--sys/contrib/openzfs/tests/zfs-tests/tests/perf/perf.shlib141
1 files changed, 59 insertions, 82 deletions
diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/perf/perf.shlib b/sys/contrib/openzfs/tests/zfs-tests/tests/perf/perf.shlib
index 5a404df083e4..27c40bd52946 100644
--- a/sys/contrib/openzfs/tests/zfs-tests/tests/perf/perf.shlib
+++ b/sys/contrib/openzfs/tests/zfs-tests/tests/perf/perf.shlib
@@ -254,7 +254,7 @@ function do_collect_scripts
# Find a place to deposit performance data collected while under load.
function get_perf_output_dir
{
- typeset dir="$(pwd)/perf_data"
+ typeset dir="$PWD/perf_data"
[[ -d $dir ]] || mkdir -p $dir
echo $dir
@@ -265,7 +265,7 @@ function apply_zinject_delays
typeset idx=0
while [[ $idx -lt "${#ZINJECT_DELAYS[@]}" ]]; do
[[ -n ${ZINJECT_DELAYS[$idx]} ]] || \
- log_must "No zinject delay found at index: $idx"
+ log_fail "No zinject delay found at index: $idx"
for disk in $DISKS; do
log_must zinject \
@@ -380,65 +380,56 @@ function get_directory
function get_min_arc_size
{
- typeset -l min_arc_size
-
- if is_freebsd; then
- min_arc_size=$(sysctl -n kstat.zfs.misc.arcstats.c_min)
- elif is_illumos; then
- min_arc_size=$(dtrace -qn 'BEGIN {
+ case "$UNAME" in
+ Linux)
+ awk '$1 == "c_min" { print $3 }' /proc/spl/kstat/zfs/arcstats
+ ;;
+ FreeBSD)
+ sysctl -n kstat.zfs.misc.arcstats.c_min
+ ;;
+ *)
+ dtrace -qn 'BEGIN {
printf("%u\n", `arc_stats.arcstat_c_min.value.ui64);
exit(0);
- }')
- elif is_linux; then
- min_arc_size=`awk '$1 == "c_min" { print $3 }' \
- /proc/spl/kstat/zfs/arcstats`
- fi
-
- [[ $? -eq 0 ]] || log_fail "get_min_arc_size failed"
-
- echo $min_arc_size
+ }'
+ ;;
+ esac || log_fail "get_min_arc_size failed"
}
function get_max_arc_size
{
- typeset -l max_arc_size
-
- if is_freebsd; then
- max_arc_size=$(sysctl -n kstat.zfs.misc.arcstats.c_max)
- elif is_illumos; then
- max_arc_size=$(dtrace -qn 'BEGIN {
+ case "$UNAME" in
+ Linux)
+ awk '$1 == "c_max" { print $3 }' /proc/spl/kstat/zfs/arcstats
+ ;;
+ FreeBSD)
+ sysctl -n kstat.zfs.misc.arcstats.c_max
+ ;;
+ *)
+ dtrace -qn 'BEGIN {
printf("%u\n", `arc_stats.arcstat_c_max.value.ui64);
exit(0);
- }')
- elif is_linux; then
- max_arc_size=`awk '$1 == "c_max" { print $3 }' \
- /proc/spl/kstat/zfs/arcstats`
- fi
-
- [[ $? -eq 0 ]] || log_fail "get_max_arc_size failed"
-
- echo $max_arc_size
+ }'
+ ;;
+ esac || log_fail "get_max_arc_size failed"
}
function get_arc_target
{
- typeset -l arc_c
-
- if is_freebsd; then
- arc_c=$(sysctl -n kstat.zfs.misc.arcstats.c)
- elif is_illumos; then
- arc_c=$(dtrace -qn 'BEGIN {
+ case "$UNAME" in
+ Linux)
+ awk '$1 == "c" { print $3 }' /proc/spl/kstat/zfs/arcstats
+ ;;
+ FreeBSD)
+ sysctl -n kstat.zfs.misc.arcstats.c
+ ;;
+ *)
+ dtrace -qn 'BEGIN {
printf("%u\n", `arc_stats.arcstat_c.value.ui64);
exit(0);
- }')
- elif is_linux; then
- arc_c=`awk '$1 == "c" { print $3 }' \
- /proc/spl/kstat/zfs/arcstats`
- fi
-
- [[ $? -eq 0 ]] || log_fail "get_arc_target failed"
-
- echo $arc_c
+ }'
+ ;;
+ esac || log_fail "get_arc_target failed"
}
function get_dbuf_cache_size
@@ -453,9 +444,7 @@ function get_dbuf_cache_size
else
dbuf_cache_shift=$(get_tunable DBUF_CACHE_SHIFT)
dbuf_cache_size=$(($(get_arc_target) / 2**dbuf_cache_shift))
- fi
-
- [[ $? -eq 0 ]] || log_fail "get_dbuf_cache_size failed"
+ fi || log_fail "get_dbuf_cache_size failed"
echo $dbuf_cache_size
}
@@ -467,7 +456,7 @@ function get_system_config
echo "{" >>$config
if is_linux; then
- echo " \"ncpus\": \"$(nproc --all)\"," >>$config
+ echo " \"ncpus\": \"$(lscpu | awk '/^CPU\(s\)/ {print $2; exit}')\"," >>$config
echo " \"physmem\": \"$(free -b | \
awk '$1 == "Mem:" { print $2 }')\"," >>$config
echo " \"c_max\": \"$(get_max_arc_size)\"," >>$config
@@ -535,20 +524,6 @@ function get_system_config
echo "}" >>$config
}
-function num_jobs_by_cpu
-{
- if is_linux; then
- typeset ncpu=$($NPROC --all)
- else
- typeset ncpu=$(psrinfo | $WC -l)
- fi
- typeset num_jobs=$ncpu
-
- [[ $ncpu -gt 8 ]] && num_jobs=$(echo "$ncpu * 3 / 4" | bc)
-
- echo $num_jobs
-}
-
#
# On illumos this looks like: ":sd3:sd4:sd1:sd2:"
#
@@ -558,32 +533,34 @@ function pool_to_lun_list
typeset ctd ctds devname lun
typeset lun_list=':'
- if is_illumos; then
- ctds=$(zpool list -v $pool |
- awk '/c[0-9]*t[0-9a-fA-F]*d[0-9]*/ {print $1}')
+ case "$UNAME" in
+ Linux)
+ ctds=$(zpool list -HLv $pool | \
+ awk '/sd[a-z]*|loop[0-9]*|dm-[0-9]*/ {print $1}')
for ctd in $ctds; do
- # Get the device name as it appears in /etc/path_to_inst
- devname=$(readlink -f /dev/dsk/${ctd}s0 | sed -n \
- 's/\/devices\([^:]*\):.*/\1/p')
- # Add a string composed of the driver name and instance
- # number to the list for comparison with dev_statname.
- lun=$(sed 's/"//g' /etc/path_to_inst | grep \
- $devname | awk '{print $3$2}')
- lun_list="$lun_list$lun:"
+ lun_list="$lun_list$ctd:"
done
- elif is_freebsd; then
+ ;;
+ FreeBSD)
lun_list+=$(zpool list -HLv $pool | \
awk '/a?da[0-9]+|md[0-9]+|mfid[0-9]+|nda[0-9]+|nvd[0-9]+|vtbd[0-9]+/
{ printf "%s:", $1 }')
- elif is_linux; then
- ctds=$(zpool list -HLv $pool | \
- awk '/sd[a-z]*|loop[0-9]*|dm-[0-9]*/ {print $1}')
+ ;;
+ *)
+ ctds=$(zpool list -v $pool |
+ awk '/c[0-9]*t[0-9a-fA-F]*d[0-9]*/ {print $1}')
for ctd in $ctds; do
- lun_list="$lun_list$ctd:"
+ # Get the device name as it appears in /etc/path_to_inst
+ devname=$(readlink -f /dev/dsk/${ctd}s0 | sed -n 's/\/devices\([^:]*\):.*/\1/p')
+ # Add a string composed of the driver name and instance
+ # number to the list for comparison with dev_statname.
+ lun=$(sed 's/"//g' /etc/path_to_inst | awk -v dn="$devname" '$0 ~ dn {print $3$2}')
+ lun_list="$lun_list$lun:"
done
- fi
+ ;;
+ esac
echo $lun_list
}