1dcbf3bd6SGeorge Wilson#!/usr/bin/ksh
2dcbf3bd6SGeorge Wilson
3dcbf3bd6SGeorge Wilson#
4dcbf3bd6SGeorge Wilson# This file and its contents are supplied under the terms of the
5dcbf3bd6SGeorge Wilson# Common Development and Distribution License ("CDDL"), version 1.0.
6dcbf3bd6SGeorge Wilson# You may only use this file in accordance with the terms of version
7dcbf3bd6SGeorge Wilson# 1.0 of the CDDL.
8dcbf3bd6SGeorge Wilson#
9dcbf3bd6SGeorge Wilson# A full copy of the text of the CDDL should have accompanied this
10dcbf3bd6SGeorge Wilson# source.  A copy of the CDDL is also available via the Internet at
11dcbf3bd6SGeorge Wilson# http://www.illumos.org/license/CDDL.
12dcbf3bd6SGeorge Wilson#
13dcbf3bd6SGeorge Wilson
14dcbf3bd6SGeorge Wilson#
151d32ba66SJohn Wren Kennedy# Copyright (c) 2015, 2016 by Delphix. All rights reserved.
16dcbf3bd6SGeorge Wilson#
17dcbf3bd6SGeorge Wilson
18dcbf3bd6SGeorge Wilson#
19dcbf3bd6SGeorge Wilson# Description:
20dcbf3bd6SGeorge Wilson# Trigger fio runs using the random_writes job file. The number of runs and
21dcbf3bd6SGeorge Wilson# data collected is determined by the PERF_* variables. See do_fio_run for
22dcbf3bd6SGeorge Wilson# details about these variables.
23dcbf3bd6SGeorge Wilson#
24dcbf3bd6SGeorge Wilson# Prior to each fio run the dataset is recreated, and fio writes new files
25dcbf3bd6SGeorge Wilson# into an otherwise empty pool.
26dcbf3bd6SGeorge Wilson#
27859bfeadSStephen Blinick# Thread/Concurrency settings:
28859bfeadSStephen Blinick#    PERF_NTHREADS defines the number of files created in the test filesystem,
29859bfeadSStephen Blinick#    as well as the number of threads that will simultaneously drive IO to
30859bfeadSStephen Blinick#    those files.  The settings chosen are from measurements in the
31859bfeadSStephen Blinick#    PerfAutoESX/ZFSPerfESX Environments, selected at concurrency levels that
32859bfeadSStephen Blinick#    are at peak throughput but lowest latency.  Higher concurrency introduces
33859bfeadSStephen Blinick#    queue time latency and would reduce the impact of code-induced performance
34859bfeadSStephen Blinick#    regressions.
35859bfeadSStephen Blinick#
36dcbf3bd6SGeorge Wilson
37dcbf3bd6SGeorge Wilson. $STF_SUITE/include/libtest.shlib
38dcbf3bd6SGeorge Wilson. $STF_SUITE/tests/perf/perf.shlib
39dcbf3bd6SGeorge Wilson
40dcbf3bd6SGeorge Wilsonfunction cleanup
41dcbf3bd6SGeorge Wilson{
42c373aa8bSJohn Wren Kennedy	recreate_perf_pool
43dcbf3bd6SGeorge Wilson}
44dcbf3bd6SGeorge Wilson
45dcbf3bd6SGeorge Wilsonlog_onexit cleanup
46dcbf3bd6SGeorge Wilson
47c373aa8bSJohn Wren Kennedyrecreate_perf_pool
48c373aa8bSJohn Wren Kennedypopulate_perf_filesystems
49dcbf3bd6SGeorge Wilson
50dcbf3bd6SGeorge Wilson# Aim to fill the pool to 50% capacity while accounting for a 3x compressratio.
51c373aa8bSJohn Wren Kennedyexport TOTAL_SIZE=$(($(get_prop avail $PERFPOOL) * 3 / 2))
52dcbf3bd6SGeorge Wilson
53dcbf3bd6SGeorge Wilson# Variables for use by fio.
54dcbf3bd6SGeorge Wilsonif [[ -n $PERF_REGRESSION_WEEKLY ]]; then
55dcbf3bd6SGeorge Wilson	export PERF_RUNTIME=${PERF_RUNTIME:-$PERF_RUNTIME_WEEKLY}
56dcbf3bd6SGeorge Wilson	export PERF_RUNTYPE=${PERF_RUNTYPE:-'weekly'}
57859bfeadSStephen Blinick	export PERF_NTHREADS=${PERF_NTHREADS:-'1 4 8 16 32 64 128'}
58c373aa8bSJohn Wren Kennedy	export PERF_NTHREADS_PER_FS=${PERF_NTHREADS_PER_FS:-'0'}
59dcbf3bd6SGeorge Wilson	export PERF_SYNC_TYPES=${PERF_SYNC_TYPES:-'0 1'}
60*65d28c0bSJohn Wren Kennedy	export PERF_IOSIZES=${PERF_IOSIZES:-'8k 64k 256k'}
61dcbf3bd6SGeorge Wilsonelif [[ -n $PERF_REGRESSION_NIGHTLY ]]; then
62dcbf3bd6SGeorge Wilson	export PERF_RUNTIME=${PERF_RUNTIME:-$PERF_RUNTIME_NIGHTLY}
63dcbf3bd6SGeorge Wilson	export PERF_RUNTYPE=${PERF_RUNTYPE:-'nightly'}
64859bfeadSStephen Blinick	export PERF_NTHREADS=${PERF_NTHREADS:-'32 128'}
65c373aa8bSJohn Wren Kennedy	export PERF_NTHREADS_PER_FS=${PERF_NTHREADS_PER_FS:-'0'}
66dcbf3bd6SGeorge Wilson	export PERF_SYNC_TYPES=${PERF_SYNC_TYPES:-'1'}
67dcbf3bd6SGeorge Wilson	export PERF_IOSIZES=${PERF_IOSIZES:-'8k'}
68dcbf3bd6SGeorge Wilsonfi
69dcbf3bd6SGeorge Wilson
70dcbf3bd6SGeorge Wilson# Set up the scripts and output files that will log performance data.
71dcbf3bd6SGeorge Wilsonlun_list=$(pool_to_lun_list $PERFPOOL)
72dcbf3bd6SGeorge Wilsonlog_note "Collecting backend IO stats with lun list $lun_list"
73c373aa8bSJohn Wren Kennedyexport collect_scripts=(
74c373aa8bSJohn Wren Kennedy    "kstat zfs:0 1"  "kstat"
75*65d28c0bSJohn Wren Kennedy    "vmstat -T d 1"       "vmstat"
76*65d28c0bSJohn Wren Kennedy    "mpstat -T d 1"       "mpstat"
77*65d28c0bSJohn Wren Kennedy    "iostat -T d -xcnz 1" "iostat"
78c373aa8bSJohn Wren Kennedy    "dtrace -Cs $PERF_SCRIPTS/io.d $PERFPOOL $lun_list 1" "io"
79c373aa8bSJohn Wren Kennedy    "dtrace  -s $PERF_SCRIPTS/profile.d"                  "profile"
80c373aa8bSJohn Wren Kennedy)
81dcbf3bd6SGeorge Wilson
82dcbf3bd6SGeorge Wilsonlog_note "Random writes with $PERF_RUNTYPE settings"
831d32ba66SJohn Wren Kennedydo_fio_run random_writes.fio true false
84dcbf3bd6SGeorge Wilsonlog_pass "Measure IO stats during random write load"
85