]> git.proxmox.com Git - mirror_zfs-debian.git/blame - scripts/zpios-survey.sh
New upstream version 0.7.5
[mirror_zfs-debian.git] / scripts / zpios-survey.sh
CommitLineData
302ef151
BB
1#!/bin/bash
2#
3# Wrapper script for easily running a survey of zpios based tests
4#
5
6basedir="$(dirname $0)"
7
8SCRIPT_COMMON=common.sh
9if [ -f "${basedir}/${SCRIPT_COMMON}" ]; then
10. "${basedir}/${SCRIPT_COMMON}"
11else
12echo "Missing helper script ${SCRIPT_COMMON}" && exit 1
13fi
14
15PROG=zpios-survey.sh
16
17usage() {
18cat << EOF
19USAGE:
20$0 [hvp] <-c config> <-t test>
21
22DESCRIPTION:
23 Helper script for easy zpios survey benchmarking.
24
25OPTIONS:
26 -h Show this message
27 -v Verbose
28 -p Enable profiling
29 -c Zpool configuration
30 -t Zpios test
31 -l Zpios survey log
32
33EOF
34}
35
36print_header() {
37tee -a ${ZPIOS_SURVEY_LOG} << EOF
38
39================================================================
40Test: $1
41EOF
42}
43
44# Baseline performance for an out of the box config with no manual tuning.
45# Ideally, we want everything to be automatically tuned for your system and
46# for this to perform reasonably well.
47zpios_survey_base() {
48 TEST_NAME="${ZPOOL_CONFIG}+${ZPIOS_TEST}+baseline"
49 print_header ${TEST_NAME}
50
51 ${ZFS_SH} ${VERBOSE_FLAG} | \
52 tee -a ${ZPIOS_SURVEY_LOG}
53 ${ZPIOS_SH} ${VERBOSE_FLAG} -c ${ZPOOL_CONFIG} -t ${ZPIOS_TEST} | \
54 tee -a ${ZPIOS_SURVEY_LOG}
55 ${ZFS_SH} -u ${VERBOSE_FLAG} | \
56 tee -a ${ZPIOS_SURVEY_LOG}
57}
58
59# Disable ZFS's prefetching. For some reason still not clear to me
60# current prefetching policy is quite bad for a random workload.
61# Allowing the algorithm to detect a random workload and not do
62# anything may be the way to address this issue.
63zpios_survey_prefetch() {
64 TEST_NAME="${ZPOOL_CONFIG}+${ZPIOS_TEST}+prefetch"
65 print_header ${TEST_NAME}
66
67 ${ZFS_SH} ${VERBOSE_FLAG} \
68 tee -a ${ZPIOS_SURVEY_LOG}
69 ${ZPIOS_SH} ${VERBOSE_FLAG} -c ${ZPOOL_CONFIG} -t ${ZPIOS_TEST} \
70 -o "--noprefetch" | \
71 tee -a ${ZPIOS_SURVEY_LOG}
72 ${ZFS_SH} -u ${VERBOSE_FLAG} | \
73 tee -a ${ZPIOS_SURVEY_LOG}
74}
75
76# Simulating a zerocopy IO path should improve performance by freeing up
77# lots of CPU which is wasted move data between buffers.
78zpios_survey_zerocopy() {
79 TEST_NAME="${ZPOOL_CONFIG}+${ZPIOS_TEST}+zerocopy"
80 print_header ${TEST_NAME}
81
82 ${ZFS_SH} ${VERBOSE_FLAG} | \
83 tee -a ${ZPIOS_SURVEY_LOG}
84 ${ZPIOS_SH} ${VERBOSE_FLAG} -c ${ZPOOL_CONFIG} -t ${ZPIOS_TEST} \
85 -o "--zerocopy" | \
86 tee -a ${ZPIOS_SURVEY_LOG}
87 ${ZFS_SH} -u ${VERBOSE_FLAG} | \
88 tee -a ${ZPIOS_SURVEY_LOG}
89}
90
91# Disabling checksumming should show some (if small) improvement
92# simply due to freeing up a modest amount of CPU.
93zpios_survey_checksum() {
94 TEST_NAME="${ZPOOL_CONFIG}+${ZPIOS_TEST}+checksum"
95 print_header ${TEST_NAME}
96
97 ${ZFS_SH} ${VERBOSE_FLAG} | \
98 tee -a ${ZPIOS_SURVEY_LOG}
99 ${ZPIOS_SH} ${VERBOSE_FLAG} -c ${ZPOOL_CONFIG} -t ${ZPIOS_TEST} \
100 -s "set checksum=off" | \
101 tee -a ${ZPIOS_SURVEY_LOG}
102 ${ZFS_SH} -u ${VERBOSE_FLAG} | \
103 tee -a ${ZPIOS_SURVEY_LOG}
104}
105
106# Increasing the pending IO depth also seems to improve things likely
107# at the expense of latency. This should be explored more because I'm
108# seeing a much bigger impact there that I would have expected. There
109# may be some low hanging fruit to be found here.
110zpios_survey_pending() {
111 TEST_NAME="${ZPOOL_CONFIG}+${ZPIOS_TEST}+pending"
112 print_header ${TEST_NAME}
113
114 ${ZFS_SH} ${VERBOSE_FLAG} \
115 zfs="zfs_vdev_max_pending=1024" | \
116 tee -a ${ZPIOS_SURVEY_LOG}
117 ${ZPIOS_SH} ${VERBOSE_FLAG} -c ${ZPOOL_CONFIG} -t ${ZPIOS_TEST} | \
118 tee -a ${ZPIOS_SURVEY_LOG}
119 ${ZFS_SH} -u ${VERBOSE_FLAG} | \
120 tee -a ${ZPIOS_SURVEY_LOG}
121}
122
302ef151
BB
123# Apply all possible turning concurrently to get a best case number
124zpios_survey_all() {
125 TEST_NAME="${ZPOOL_CONFIG}+${ZPIOS_TEST}+all"
126 print_header ${TEST_NAME}
127
128 ${ZFS_SH} ${VERBOSE_FLAG} \
ea04106b 129 zfs="zfs_vdev_max_pending=1024" | \
302ef151
BB
130 tee -a ${ZPIOS_SURVEY_LOG}
131 ${ZPIOS_SH} ${VERBOSE_FLAG} -c ${ZPOOL_CONFIG} -t ${ZPIOS_TEST} \
132 -o "--noprefetch --zerocopy" \
133 -s "set checksum=off" | \
134 tee -a ${ZPIOS_SURVEY_LOG}
135 ${ZFS_SH} -u ${VERBOSE_FLAG} | \
136 tee -a ${ZPIOS_SURVEY_LOG}
137}
138
139
140PROFILE=
141ZPOOL_NAME=zpios-survey
142ZPOOL_CONFIG=zpool-config.sh
143ZPIOS_TEST=zpios-test.sh
144ZPIOS_SURVEY_LOG=/dev/null
145
146while getopts 'hvpc:t:l:' OPTION; do
147 case $OPTION in
148 h)
149 usage
150 exit 1
151 ;;
152 v)
153 VERBOSE=1
154 VERBOSE_FLAG="-v"
155 ;;
156 p)
157 PROFILE=1
158 PROFILE_FLAG="-p"
159 ;;
160 c)
161 ZPOOL_CONFIG=${OPTARG}
162 ;;
163 t)
164 ZPIOS_TEST=${OPTARG}
165 ;;
166 l)
167 ZPIOS_SURVEY_LOG=${OPTARG}
168 ;;
169 ?)
170 usage
171 exit
172 ;;
173 esac
174done
175
176if [ $(id -u) != 0 ]; then
177 die "Must run as root"
178fi
179
180zpios_survey_base
181zpios_survey_prefetch
182zpios_survey_zerocopy
183zpios_survey_checksum
184zpios_survey_pending
302ef151
BB
185zpios_survey_all
186
187exit 0