3 # Wrapper script for easily running a survey of zpios based tests
6 basedir="$(dirname $0)"
8 SCRIPT_COMMON=common.sh
9 if [ -f "${basedir}/${SCRIPT_COMMON}" ]; then
10 . "${basedir}/${SCRIPT_COMMON}"
12 echo "Missing helper script ${SCRIPT_COMMON}" && exit 1
20 $0 [hvp] <-c config> <-t test>
23 Helper script for easy zpios survey benchmarking.
29 -c Zpool configuration
37 tee -a ${ZPIOS_SURVEY_LOG} << EOF
39 ================================================================
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.
48 TEST_NAME="${ZPOOL_CONFIG}+${ZPIOS_TEST}+baseline"
49 print_header ${TEST_NAME}
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}
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.
63 zpios_survey_prefetch() {
64 TEST_NAME="${ZPOOL_CONFIG}+${ZPIOS_TEST}+prefetch"
65 print_header ${TEST_NAME}
67 ${ZFS_SH} ${VERBOSE_FLAG} \
68 tee -a ${ZPIOS_SURVEY_LOG}
69 ${ZPIOS_SH} ${VERBOSE_FLAG} -c ${ZPOOL_CONFIG} -t ${ZPIOS_TEST} \
71 tee -a ${ZPIOS_SURVEY_LOG}
72 ${ZFS_SH} -u ${VERBOSE_FLAG} | \
73 tee -a ${ZPIOS_SURVEY_LOG}
76 # Simulating a zerocopy IO path should improve performance by freeing up
77 # lots of CPU which is wasted move data between buffers.
78 zpios_survey_zerocopy() {
79 TEST_NAME="${ZPOOL_CONFIG}+${ZPIOS_TEST}+zerocopy"
80 print_header ${TEST_NAME}
82 ${ZFS_SH} ${VERBOSE_FLAG} | \
83 tee -a ${ZPIOS_SURVEY_LOG}
84 ${ZPIOS_SH} ${VERBOSE_FLAG} -c ${ZPOOL_CONFIG} -t ${ZPIOS_TEST} \
86 tee -a ${ZPIOS_SURVEY_LOG}
87 ${ZFS_SH} -u ${VERBOSE_FLAG} | \
88 tee -a ${ZPIOS_SURVEY_LOG}
91 # Disabling checksumming should show some (if small) improvement
92 # simply due to freeing up a modest amount of CPU.
93 zpios_survey_checksum() {
94 TEST_NAME="${ZPOOL_CONFIG}+${ZPIOS_TEST}+checksum"
95 print_header ${TEST_NAME}
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}
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.
110 zpios_survey_pending() {
111 TEST_NAME="${ZPOOL_CONFIG}+${ZPIOS_TEST}+pending"
112 print_header ${TEST_NAME}
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}
123 # To avoid memory fragmentation issues our slab implementation can be
124 # based on a virtual address space. Interestingly, we take a pretty
125 # substantial performance penalty for this somewhere in the low level
126 # IO drivers. If we back the slab with kmem pages we see far better
127 # read performance numbers at the cost of memory fragmention and general
128 # system instability due to large allocations. This may be because of
129 # an optimization in the low level drivers due to the contigeous kmem
130 # based memory. This needs to be explained. The good news here is that
131 # with zerocopy interfaces added at the DMU layer we could gaurentee
132 # kmem based memory for a pool of pages.
134 # 0x100 = KMC_KMEM - Force kmem_* based slab
135 # 0x200 = KMC_VMEM - Force vmem_* based slab
136 zpios_survey_kmem() {
137 TEST_NAME="${ZPOOL_CONFIG}+${ZPIOS_TEST}+kmem"
138 print_header ${TEST_NAME}
140 ${ZFS_SH} ${VERBOSE_FLAG} \
141 zfs="zio_bulk_flags=0x100" | \
142 tee -a ${ZPIOS_SURVEY_LOG}
143 ${ZPIOS_SH} ${VERBOSE_FLAG} -c ${ZPOOL_CONFIG} -t ${ZPIOS_TEST} | \
144 tee -a ${ZPIOS_SURVEY_LOG}
145 ${ZFS_SH} -u ${VERBOSE_FLAG} | \
146 tee -a ${ZPIOS_SURVEY_LOG}
149 # Apply all possible turning concurrently to get a best case number
151 TEST_NAME="${ZPOOL_CONFIG}+${ZPIOS_TEST}+all"
152 print_header ${TEST_NAME}
154 ${ZFS_SH} ${VERBOSE_FLAG} \
155 zfs="zfs_vdev_max_pending=1024" \
156 zfs="zio_bulk_flags=0x100" | \
157 tee -a ${ZPIOS_SURVEY_LOG}
158 ${ZPIOS_SH} ${VERBOSE_FLAG} -c ${ZPOOL_CONFIG} -t ${ZPIOS_TEST} \
159 -o "--noprefetch --zerocopy" \
160 -s "set checksum=off" | \
161 tee -a ${ZPIOS_SURVEY_LOG}
162 ${ZFS_SH} -u ${VERBOSE_FLAG} | \
163 tee -a ${ZPIOS_SURVEY_LOG}
168 ZPOOL_NAME=zpios-survey
169 ZPOOL_CONFIG=zpool-config.sh
170 ZPIOS_TEST=zpios-test.sh
171 ZPIOS_SURVEY_LOG=/dev/null
173 while getopts 'hvpc:t:l:' OPTION; do
188 ZPOOL_CONFIG=${OPTARG}
194 ZPIOS_SURVEY_LOG=${OPTARG}
203 if [ $(id -u) != 0 ]; then
204 die "Must run as root"
208 zpios_survey_prefetch
209 zpios_survey_zerocopy
210 zpios_survey_checksum