1#!/bin/ksh 2 3# This file and its contents are supplied under the terms of the 4# Common Development and Distribution License ("CDDL"), version 1.0. 5# You may only use this file in accordance with the terms of version 6# 1.0 of the CDDL. 7# 8# A full copy of the text of the CDDL should have accompanied this 9# source. A copy of the CDDL is also available via the Internet at 10# http://www.illumos.org/license/CDDL. 11# 12 13# 14# Copyright (c) 2017, 2021 by Delphix. All rights reserved. 15# 16 17# 18# Description: 19# Trigger fio runs using the random_readwrite_fixed job file. The number of runs and 20# data collected is determined by the PERF_* variables. See do_fio_run for 21# details about these variables. 22# 23# The files to read and write from are created prior to the first fio run, 24# and used for all fio runs. The ARC is cleared with `zinject -a` prior to 25# each run so reads will go to disk. 26# 27 28. $STF_SUITE/include/libtest.shlib 29. $STF_SUITE/tests/perf/perf.shlib 30 31command -v fio > /dev/null || log_unsupported "fio missing" 32 33function cleanup 34{ 35 # kill fio and iostat 36 pkill fio 37 pkill iostat 38 recreate_perf_pool 39} 40 41trap "log_fail \"Measure IO stats during random read write load\"" SIGTERM 42log_onexit cleanup 43 44recreate_perf_pool 45populate_perf_filesystems 46 47# Aim to fill the pool to 50% capacity while accounting for a 3x compressratio. 48export TOTAL_SIZE=$(($(get_prop avail $PERFPOOL) * 3 / 2)) 49 50# Variables specific to this test for use by fio. 51export PERF_NTHREADS=${PERF_NTHREADS:-'64 128'} 52export PERF_NTHREADS_PER_FS=${PERF_NTHREADS_PER_FS:-'0'} 53export PERF_IOSIZES=${PERF_IOSIZES:-'8k'} 54export PERF_SYNC_TYPES=${PERF_SYNC_TYPES:-'0 1'} 55 56# Layout the files to be used by the readwrite tests. Create as many files 57# as the largest number of threads. An fio run with fewer threads will use 58# a subset of the available files. 59export NUMJOBS=$(get_max $PERF_NTHREADS) 60export FILE_SIZE=$((TOTAL_SIZE / NUMJOBS)) 61export DIRECTORY=$(get_directory) 62log_must fio $FIO_SCRIPTS/mkfiles.fio 63 64# Set up the scripts and output files that will log performance data. 65lun_list=$(pool_to_lun_list $PERFPOOL) 66log_note "Collecting backend IO stats with lun list $lun_list" 67if is_linux; then 68 typeset perf_record_cmd="perf record -F 99 -a -g -q \ 69 -o /dev/stdout -- sleep ${PERF_RUNTIME}" 70 71 export collect_scripts=( 72 "zpool iostat -lpvyL $PERFPOOL 1" "zpool.iostat" 73 "vmstat -t 1" "vmstat" 74 "mpstat -P ALL 1" "mpstat" 75 "iostat -tdxyz 1" "iostat" 76 "$perf_record_cmd" "perf" 77 ) 78else 79 export collect_scripts=( 80 "kstat zfs:0 1" "kstat" 81 "vmstat -T d 1" "vmstat" 82 "mpstat -T d 1" "mpstat" 83 "iostat -T d -xcnz 1" "iostat" 84 "dtrace -Cs $PERF_SCRIPTS/io.d $PERFPOOL $lun_list 1" "io" 85 "dtrace -s $PERF_SCRIPTS/profile.d" "profile" 86 ) 87fi 88 89log_note "Random reads and writes with settings: $(print_perf_settings)" 90do_fio_run random_readwrite_fixed.fio false true 91log_pass "Measure IO stats during random read and write load" 92