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