koder aka kdanilov | cff7b2e | 2015-04-18 20:48:15 +0300 | [diff] [blame] | 1 | import os |
koder aka kdanilov | 88407ff | 2015-05-26 15:35:57 +0300 | [diff] [blame] | 2 | import csv |
koder aka kdanilov | 4a510ee | 2015-04-21 18:50:42 +0300 | [diff] [blame] | 3 | import bisect |
koder aka kdanilov | a047e1b | 2015-04-21 23:16:59 +0300 | [diff] [blame] | 4 | import logging |
koder aka kdanilov | 88407ff | 2015-05-26 15:35:57 +0300 | [diff] [blame] | 5 | import itertools |
koder aka kdanilov | 416b87a | 2015-05-12 00:26:04 +0300 | [diff] [blame] | 6 | import collections |
koder aka kdanilov | 4af1c1d | 2015-05-18 15:48:58 +0300 | [diff] [blame] | 7 | from cStringIO import StringIO |
koder aka kdanilov | cff7b2e | 2015-04-18 20:48:15 +0300 | [diff] [blame] | 8 | |
koder aka kdanilov | be8f89f | 2015-04-28 14:51:51 +0300 | [diff] [blame] | 9 | try: |
koder aka kdanilov | 4af1c1d | 2015-05-18 15:48:58 +0300 | [diff] [blame] | 10 | import numpy |
| 11 | import scipy |
koder aka kdanilov | 0fdaaee | 2015-06-30 11:10:48 +0300 | [diff] [blame] | 12 | import matplotlib |
koder aka kdanilov | 9e0512a | 2015-08-10 14:51:59 +0300 | [diff] [blame] | 13 | matplotlib.use('svg') |
koder aka kdanilov | be8f89f | 2015-04-28 14:51:51 +0300 | [diff] [blame] | 14 | import matplotlib.pyplot as plt |
| 15 | except ImportError: |
| 16 | plt = None |
| 17 | |
koder aka kdanilov | 4a510ee | 2015-04-21 18:50:42 +0300 | [diff] [blame] | 18 | import wally |
koder aka kdanilov | f86d7af | 2015-05-06 04:01:54 +0300 | [diff] [blame] | 19 | from wally.utils import ssize2b |
koder aka kdanilov | bb6d6cd | 2015-06-20 02:55:07 +0300 | [diff] [blame] | 20 | from wally.statistic import round_3_digit |
koder aka kdanilov | 88407ff | 2015-05-26 15:35:57 +0300 | [diff] [blame] | 21 | from wally.suits.io.fio_task_parser import (get_test_sync_mode, |
| 22 | get_test_summary, |
| 23 | parse_all_in_1, |
| 24 | abbv_name_to_full) |
koder aka kdanilov | cff7b2e | 2015-04-18 20:48:15 +0300 | [diff] [blame] | 25 | |
koder aka kdanilov | 4a510ee | 2015-04-21 18:50:42 +0300 | [diff] [blame] | 26 | |
koder aka kdanilov | a047e1b | 2015-04-21 23:16:59 +0300 | [diff] [blame] | 27 | logger = logging.getLogger("wally.report") |
| 28 | |
| 29 | |
koder aka kdanilov | 209e85d | 2015-04-27 23:11:05 +0300 | [diff] [blame] | 30 | class DiskInfo(object): |
| 31 | def __init__(self): |
| 32 | self.direct_iops_r_max = 0 |
| 33 | self.direct_iops_w_max = 0 |
koder aka kdanilov | 88407ff | 2015-05-26 15:35:57 +0300 | [diff] [blame] | 34 | |
| 35 | # 64 used instead of 4k to faster feed caches |
| 36 | self.direct_iops_w64_max = 0 |
| 37 | |
koder aka kdanilov | 209e85d | 2015-04-27 23:11:05 +0300 | [diff] [blame] | 38 | self.rws4k_10ms = 0 |
| 39 | self.rws4k_30ms = 0 |
| 40 | self.rws4k_100ms = 0 |
| 41 | self.bw_write_max = 0 |
| 42 | self.bw_read_max = 0 |
| 43 | |
| 44 | |
koder aka kdanilov | be8f89f | 2015-04-28 14:51:51 +0300 | [diff] [blame] | 45 | report_funcs = [] |
| 46 | |
| 47 | |
koder aka kdanilov | 4af1c1d | 2015-05-18 15:48:58 +0300 | [diff] [blame] | 48 | class Attrmapper(object): |
| 49 | def __init__(self, dct): |
| 50 | self.__dct = dct |
| 51 | |
| 52 | def __getattr__(self, name): |
| 53 | try: |
| 54 | return self.__dct[name] |
| 55 | except KeyError: |
| 56 | raise AttributeError(name) |
| 57 | |
| 58 | |
koder aka kdanilov | f86d7af | 2015-05-06 04:01:54 +0300 | [diff] [blame] | 59 | class PerfInfo(object): |
koder aka kdanilov | 4af1c1d | 2015-05-18 15:48:58 +0300 | [diff] [blame] | 60 | def __init__(self, name, summary, intervals, params, testnodes_count): |
koder aka kdanilov | f86d7af | 2015-05-06 04:01:54 +0300 | [diff] [blame] | 61 | self.name = name |
| 62 | self.bw = None |
| 63 | self.iops = None |
| 64 | self.lat = None |
koder aka kdanilov | 88407ff | 2015-05-26 15:35:57 +0300 | [diff] [blame] | 65 | self.lat_50 = None |
| 66 | self.lat_95 = None |
koder aka kdanilov | 4af1c1d | 2015-05-18 15:48:58 +0300 | [diff] [blame] | 67 | |
| 68 | self.raw_bw = [] |
| 69 | self.raw_iops = [] |
| 70 | self.raw_lat = [] |
| 71 | |
koder aka kdanilov | 416b87a | 2015-05-12 00:26:04 +0300 | [diff] [blame] | 72 | self.params = params |
| 73 | self.intervals = intervals |
| 74 | self.testnodes_count = testnodes_count |
koder aka kdanilov | 4af1c1d | 2015-05-18 15:48:58 +0300 | [diff] [blame] | 75 | self.summary = summary |
| 76 | self.p = Attrmapper(self.params.vals) |
koder aka kdanilov | f86d7af | 2015-05-06 04:01:54 +0300 | [diff] [blame] | 77 | |
koder aka kdanilov | 4af1c1d | 2015-05-18 15:48:58 +0300 | [diff] [blame] | 78 | self.sync_mode = get_test_sync_mode(self.params) |
| 79 | self.concurence = self.params.vals.get('numjobs', 1) |
koder aka kdanilov | f86d7af | 2015-05-06 04:01:54 +0300 | [diff] [blame] | 80 | |
| 81 | |
koder aka kdanilov | fd2cfa5 | 2015-05-20 03:17:42 +0300 | [diff] [blame] | 82 | # disk_info = None |
| 83 | # base = None |
| 84 | # linearity = None |
| 85 | |
| 86 | |
koder aka kdanilov | 416b87a | 2015-05-12 00:26:04 +0300 | [diff] [blame] | 87 | def group_by_name(test_data): |
| 88 | name_map = collections.defaultdict(lambda: []) |
| 89 | |
koder aka kdanilov | 4af1c1d | 2015-05-18 15:48:58 +0300 | [diff] [blame] | 90 | for data in test_data: |
koder aka kdanilov | bb6d6cd | 2015-06-20 02:55:07 +0300 | [diff] [blame] | 91 | name_map[(data.name, data.summary())].append(data) |
koder aka kdanilov | 416b87a | 2015-05-12 00:26:04 +0300 | [diff] [blame] | 92 | |
| 93 | return name_map |
| 94 | |
| 95 | |
koder aka kdanilov | be8f89f | 2015-04-28 14:51:51 +0300 | [diff] [blame] | 96 | def report(name, required_fields): |
| 97 | def closure(func): |
| 98 | report_funcs.append((required_fields.split(","), name, func)) |
| 99 | return func |
| 100 | return closure |
| 101 | |
| 102 | |
koder aka kdanilov | 4af1c1d | 2015-05-18 15:48:58 +0300 | [diff] [blame] | 103 | def get_test_lcheck_params(pinfo): |
| 104 | res = [{ |
| 105 | 's': 'sync', |
| 106 | 'd': 'direct', |
| 107 | 'a': 'async', |
| 108 | 'x': 'sync direct' |
| 109 | }[pinfo.sync_mode]] |
koder aka kdanilov | be8f89f | 2015-04-28 14:51:51 +0300 | [diff] [blame] | 110 | |
koder aka kdanilov | 4af1c1d | 2015-05-18 15:48:58 +0300 | [diff] [blame] | 111 | res.append(pinfo.p.rw) |
koder aka kdanilov | be8f89f | 2015-04-28 14:51:51 +0300 | [diff] [blame] | 112 | |
koder aka kdanilov | 4af1c1d | 2015-05-18 15:48:58 +0300 | [diff] [blame] | 113 | return " ".join(res) |
koder aka kdanilov | 63e9c5a | 2015-04-28 23:06:07 +0300 | [diff] [blame] | 114 | |
| 115 | |
koder aka kdanilov | 4af1c1d | 2015-05-18 15:48:58 +0300 | [diff] [blame] | 116 | def get_emb_data_svg(plt): |
| 117 | sio = StringIO() |
| 118 | plt.savefig(sio, format='svg') |
| 119 | img_start = "<!-- Created with matplotlib (http://matplotlib.org/) -->" |
| 120 | return sio.getvalue().split(img_start, 1)[1] |
koder aka kdanilov | be8f89f | 2015-04-28 14:51:51 +0300 | [diff] [blame] | 121 | |
| 122 | |
koder aka kdanilov | 4af1c1d | 2015-05-18 15:48:58 +0300 | [diff] [blame] | 123 | def get_template(templ_name): |
koder aka kdanilov | 4a510ee | 2015-04-21 18:50:42 +0300 | [diff] [blame] | 124 | very_root_dir = os.path.dirname(os.path.dirname(wally.__file__)) |
| 125 | templ_dir = os.path.join(very_root_dir, 'report_templates') |
koder aka kdanilov | f86d7af | 2015-05-06 04:01:54 +0300 | [diff] [blame] | 126 | templ_file = os.path.join(templ_dir, templ_name) |
koder aka kdanilov | 4af1c1d | 2015-05-18 15:48:58 +0300 | [diff] [blame] | 127 | return open(templ_file, 'r').read() |
koder aka kdanilov | 209e85d | 2015-04-27 23:11:05 +0300 | [diff] [blame] | 128 | |
koder aka kdanilov | 4af1c1d | 2015-05-18 15:48:58 +0300 | [diff] [blame] | 129 | |
koder aka kdanilov | 88407ff | 2015-05-26 15:35:57 +0300 | [diff] [blame] | 130 | def group_by(data, func): |
| 131 | if len(data) < 2: |
| 132 | yield data |
| 133 | return |
| 134 | |
| 135 | ndata = [(func(dt), dt) for dt in data] |
| 136 | ndata.sort(key=func) |
| 137 | pkey, dt = ndata[0] |
| 138 | curr_list = [dt] |
| 139 | |
| 140 | for key, val in ndata[1:]: |
| 141 | if pkey != key: |
| 142 | yield curr_list |
| 143 | curr_list = [val] |
| 144 | else: |
| 145 | curr_list.append(val) |
| 146 | pkey = key |
| 147 | |
| 148 | yield curr_list |
| 149 | |
| 150 | |
koder aka kdanilov | 4af1c1d | 2015-05-18 15:48:58 +0300 | [diff] [blame] | 151 | @report('linearity', 'linearity_test') |
koder aka kdanilov | 88407ff | 2015-05-26 15:35:57 +0300 | [diff] [blame] | 152 | def linearity_report(processed_results, lab_info, comment): |
| 153 | labels_and_data_mp = collections.defaultdict(lambda: []) |
| 154 | vls = {} |
koder aka kdanilov | 4af1c1d | 2015-05-18 15:48:58 +0300 | [diff] [blame] | 155 | |
koder aka kdanilov | 88407ff | 2015-05-26 15:35:57 +0300 | [diff] [blame] | 156 | # plot io_time = func(bsize) |
koder aka kdanilov | 4af1c1d | 2015-05-18 15:48:58 +0300 | [diff] [blame] | 157 | for res in processed_results.values(): |
| 158 | if res.name.startswith('linearity_test'): |
| 159 | iotimes = [1000. / val for val in res.iops.raw] |
koder aka kdanilov | 88407ff | 2015-05-26 15:35:57 +0300 | [diff] [blame] | 160 | |
| 161 | op_summ = get_test_summary(res.params)[:3] |
| 162 | |
| 163 | labels_and_data_mp[op_summ].append( |
| 164 | [res.p.blocksize, res.iops.raw, iotimes]) |
| 165 | |
koder aka kdanilov | 4af1c1d | 2015-05-18 15:48:58 +0300 | [diff] [blame] | 166 | cvls = res.params.vals.copy() |
| 167 | del cvls['blocksize'] |
koder aka kdanilov | 88407ff | 2015-05-26 15:35:57 +0300 | [diff] [blame] | 168 | del cvls['rw'] |
koder aka kdanilov | 4af1c1d | 2015-05-18 15:48:58 +0300 | [diff] [blame] | 169 | |
koder aka kdanilov | 88407ff | 2015-05-26 15:35:57 +0300 | [diff] [blame] | 170 | cvls.pop('sync', None) |
| 171 | cvls.pop('direct', None) |
| 172 | cvls.pop('buffered', None) |
| 173 | |
| 174 | if op_summ not in vls: |
| 175 | vls[op_summ] = cvls |
| 176 | else: |
| 177 | assert cvls == vls[op_summ] |
| 178 | |
| 179 | all_labels = None |
koder aka kdanilov | 4af1c1d | 2015-05-18 15:48:58 +0300 | [diff] [blame] | 180 | _, ax1 = plt.subplots() |
koder aka kdanilov | 88407ff | 2015-05-26 15:35:57 +0300 | [diff] [blame] | 181 | for name, labels_and_data in labels_and_data_mp.items(): |
| 182 | labels_and_data.sort(key=lambda x: ssize2b(x[0])) |
koder aka kdanilov | 4af1c1d | 2015-05-18 15:48:58 +0300 | [diff] [blame] | 183 | |
koder aka kdanilov | 88407ff | 2015-05-26 15:35:57 +0300 | [diff] [blame] | 184 | labels, _, iotimes = zip(*labels_and_data) |
koder aka kdanilov | 4af1c1d | 2015-05-18 15:48:58 +0300 | [diff] [blame] | 185 | |
koder aka kdanilov | 88407ff | 2015-05-26 15:35:57 +0300 | [diff] [blame] | 186 | if all_labels is None: |
| 187 | all_labels = labels |
| 188 | else: |
| 189 | assert all_labels == labels |
koder aka kdanilov | 4af1c1d | 2015-05-18 15:48:58 +0300 | [diff] [blame] | 190 | |
koder aka kdanilov | 88407ff | 2015-05-26 15:35:57 +0300 | [diff] [blame] | 191 | plt.boxplot(iotimes) |
| 192 | if len(labels_and_data) > 2 and \ |
| 193 | ssize2b(labels_and_data[-2][0]) >= 4096: |
koder aka kdanilov | 4af1c1d | 2015-05-18 15:48:58 +0300 | [diff] [blame] | 194 | |
koder aka kdanilov | 88407ff | 2015-05-26 15:35:57 +0300 | [diff] [blame] | 195 | xt = range(1, len(labels) + 1) |
koder aka kdanilov | 4af1c1d | 2015-05-18 15:48:58 +0300 | [diff] [blame] | 196 | |
koder aka kdanilov | 88407ff | 2015-05-26 15:35:57 +0300 | [diff] [blame] | 197 | def io_time(sz, bw, initial_lat): |
| 198 | return sz / bw + initial_lat |
koder aka kdanilov | 4af1c1d | 2015-05-18 15:48:58 +0300 | [diff] [blame] | 199 | |
koder aka kdanilov | 88407ff | 2015-05-26 15:35:57 +0300 | [diff] [blame] | 200 | x = numpy.array(map(ssize2b, labels)) |
| 201 | y = numpy.array([sum(dt) / len(dt) for dt in iotimes]) |
| 202 | popt, _ = scipy.optimize.curve_fit(io_time, x, y, p0=(100., 1.)) |
koder aka kdanilov | 4af1c1d | 2015-05-18 15:48:58 +0300 | [diff] [blame] | 203 | |
koder aka kdanilov | 88407ff | 2015-05-26 15:35:57 +0300 | [diff] [blame] | 204 | y1 = io_time(x, *popt) |
| 205 | plt.plot(xt, y1, linestyle='--', |
| 206 | label=name + ' LS linear approx') |
koder aka kdanilov | 4af1c1d | 2015-05-18 15:48:58 +0300 | [diff] [blame] | 207 | |
koder aka kdanilov | 88407ff | 2015-05-26 15:35:57 +0300 | [diff] [blame] | 208 | for idx, (sz, _, _) in enumerate(labels_and_data): |
| 209 | if ssize2b(sz) >= 4096: |
| 210 | break |
| 211 | |
| 212 | bw = (x[-1] - x[idx]) / (y[-1] - y[idx]) |
| 213 | lat = y[-1] - x[-1] / bw |
| 214 | y2 = io_time(x, bw, lat) |
| 215 | plt.plot(xt, y2, linestyle='--', |
| 216 | label=abbv_name_to_full(name) + |
| 217 | ' (4k & max) linear approx') |
koder aka kdanilov | 4af1c1d | 2015-05-18 15:48:58 +0300 | [diff] [blame] | 218 | |
| 219 | plt.setp(ax1, xticklabels=labels) |
| 220 | |
| 221 | plt.xlabel("Block size") |
| 222 | plt.ylabel("IO time, ms") |
| 223 | |
koder aka kdanilov | fd2cfa5 | 2015-05-20 03:17:42 +0300 | [diff] [blame] | 224 | plt.subplots_adjust(top=0.85) |
koder aka kdanilov | 88407ff | 2015-05-26 15:35:57 +0300 | [diff] [blame] | 225 | plt.legend(bbox_to_anchor=(0.5, 1.15), |
| 226 | loc='upper center', |
| 227 | prop={'size': 10}, ncol=2) |
koder aka kdanilov | 4af1c1d | 2015-05-18 15:48:58 +0300 | [diff] [blame] | 228 | plt.grid() |
| 229 | iotime_plot = get_emb_data_svg(plt) |
koder aka kdanilov | fd2cfa5 | 2015-05-20 03:17:42 +0300 | [diff] [blame] | 230 | plt.clf() |
koder aka kdanilov | 4af1c1d | 2015-05-18 15:48:58 +0300 | [diff] [blame] | 231 | |
koder aka kdanilov | 88407ff | 2015-05-26 15:35:57 +0300 | [diff] [blame] | 232 | # plot IOPS = func(bsize) |
koder aka kdanilov | 4af1c1d | 2015-05-18 15:48:58 +0300 | [diff] [blame] | 233 | _, ax1 = plt.subplots() |
koder aka kdanilov | 4af1c1d | 2015-05-18 15:48:58 +0300 | [diff] [blame] | 234 | |
koder aka kdanilov | 88407ff | 2015-05-26 15:35:57 +0300 | [diff] [blame] | 235 | for name, labels_and_data in labels_and_data_mp.items(): |
| 236 | labels_and_data.sort(key=lambda x: ssize2b(x[0])) |
| 237 | _, data, _ = zip(*labels_and_data) |
| 238 | plt.boxplot(data) |
| 239 | avg = [float(sum(arr)) / len(arr) for arr in data] |
| 240 | xt = range(1, len(data) + 1) |
| 241 | plt.plot(xt, avg, linestyle='--', |
| 242 | label=abbv_name_to_full(name) + " avg") |
| 243 | |
| 244 | plt.setp(ax1, xticklabels=labels) |
koder aka kdanilov | 4af1c1d | 2015-05-18 15:48:58 +0300 | [diff] [blame] | 245 | plt.xlabel("Block size") |
| 246 | plt.ylabel("IOPS") |
koder aka kdanilov | 88407ff | 2015-05-26 15:35:57 +0300 | [diff] [blame] | 247 | plt.legend(bbox_to_anchor=(0.5, 1.15), |
| 248 | loc='upper center', |
| 249 | prop={'size': 10}, ncol=2) |
koder aka kdanilov | 4af1c1d | 2015-05-18 15:48:58 +0300 | [diff] [blame] | 250 | plt.grid() |
koder aka kdanilov | fd2cfa5 | 2015-05-20 03:17:42 +0300 | [diff] [blame] | 251 | plt.subplots_adjust(top=0.85) |
koder aka kdanilov | 4af1c1d | 2015-05-18 15:48:58 +0300 | [diff] [blame] | 252 | |
| 253 | iops_plot = get_emb_data_svg(plt) |
| 254 | |
koder aka kdanilov | 88407ff | 2015-05-26 15:35:57 +0300 | [diff] [blame] | 255 | res = set(get_test_lcheck_params(res) for res in processed_results.values()) |
| 256 | ncount = list(set(res.testnodes_count for res in processed_results.values())) |
| 257 | conc = list(set(res.concurence for res in processed_results.values())) |
| 258 | |
| 259 | assert len(conc) == 1 |
| 260 | assert len(ncount) == 1 |
| 261 | |
koder aka kdanilov | 4af1c1d | 2015-05-18 15:48:58 +0300 | [diff] [blame] | 262 | descr = { |
koder aka kdanilov | 88407ff | 2015-05-26 15:35:57 +0300 | [diff] [blame] | 263 | 'vm_count': ncount[0], |
| 264 | 'concurence': conc[0], |
| 265 | 'oper_descr': ", ".join(res).capitalize() |
koder aka kdanilov | 4af1c1d | 2015-05-18 15:48:58 +0300 | [diff] [blame] | 266 | } |
| 267 | |
| 268 | params_map = {'iotime_vs_size': iotime_plot, |
| 269 | 'iops_vs_size': iops_plot, |
| 270 | 'descr': descr} |
| 271 | |
koder aka kdanilov | 88407ff | 2015-05-26 15:35:57 +0300 | [diff] [blame] | 272 | return get_template('report_linearity.html').format(**params_map) |
koder aka kdanilov | 4af1c1d | 2015-05-18 15:48:58 +0300 | [diff] [blame] | 273 | |
| 274 | |
| 275 | @report('lat_vs_iops', 'lat_vs_iops') |
koder aka kdanilov | 88407ff | 2015-05-26 15:35:57 +0300 | [diff] [blame] | 276 | def lat_vs_iops(processed_results, lab_info, comment): |
koder aka kdanilov | 4af1c1d | 2015-05-18 15:48:58 +0300 | [diff] [blame] | 277 | lat_iops = collections.defaultdict(lambda: []) |
koder aka kdanilov | fd2cfa5 | 2015-05-20 03:17:42 +0300 | [diff] [blame] | 278 | requsted_vs_real = collections.defaultdict(lambda: {}) |
| 279 | |
koder aka kdanilov | 4af1c1d | 2015-05-18 15:48:58 +0300 | [diff] [blame] | 280 | for res in processed_results.values(): |
| 281 | if res.name.startswith('lat_vs_iops'): |
koder aka kdanilov | f236b9c | 2015-06-24 18:17:22 +0300 | [diff] [blame] | 282 | lat_iops[res.concurence].append((res.lat, |
| 283 | 0, |
koder aka kdanilov | 4af1c1d | 2015-05-18 15:48:58 +0300 | [diff] [blame] | 284 | res.iops.average, |
| 285 | res.iops.deviation)) |
koder aka kdanilov | f236b9c | 2015-06-24 18:17:22 +0300 | [diff] [blame] | 286 | # lat_iops[res.concurence].append((res.lat.average / 1000.0, |
| 287 | # res.lat.deviation / 1000.0, |
| 288 | # res.iops.average, |
| 289 | # res.iops.deviation)) |
koder aka kdanilov | fd2cfa5 | 2015-05-20 03:17:42 +0300 | [diff] [blame] | 290 | requested_iops = res.p.rate_iops * res.concurence |
| 291 | requsted_vs_real[res.concurence][requested_iops] = \ |
| 292 | (res.iops.average, res.iops.deviation) |
koder aka kdanilov | 4af1c1d | 2015-05-18 15:48:58 +0300 | [diff] [blame] | 293 | |
koder aka kdanilov | fd2cfa5 | 2015-05-20 03:17:42 +0300 | [diff] [blame] | 294 | colors = ['red', 'green', 'blue', 'orange', 'magenta', "teal"] |
| 295 | colors_it = iter(colors) |
koder aka kdanilov | 4af1c1d | 2015-05-18 15:48:58 +0300 | [diff] [blame] | 296 | for conc, lat_iops in sorted(lat_iops.items()): |
| 297 | lat, dev, iops, iops_dev = zip(*lat_iops) |
| 298 | plt.errorbar(iops, lat, xerr=iops_dev, yerr=dev, fmt='ro', |
| 299 | label=str(conc) + " threads", |
koder aka kdanilov | fd2cfa5 | 2015-05-20 03:17:42 +0300 | [diff] [blame] | 300 | color=next(colors_it)) |
koder aka kdanilov | 4af1c1d | 2015-05-18 15:48:58 +0300 | [diff] [blame] | 301 | |
| 302 | plt.xlabel("IOPS") |
| 303 | plt.ylabel("Latency, ms") |
| 304 | plt.grid() |
| 305 | plt.legend(loc=0) |
koder aka kdanilov | fd2cfa5 | 2015-05-20 03:17:42 +0300 | [diff] [blame] | 306 | plt_iops_vs_lat = get_emb_data_svg(plt) |
| 307 | plt.clf() |
| 308 | |
| 309 | colors_it = iter(colors) |
| 310 | for conc, req_vs_real in sorted(requsted_vs_real.items()): |
| 311 | req, real = zip(*sorted(req_vs_real.items())) |
| 312 | iops, dev = zip(*real) |
| 313 | plt.errorbar(req, iops, yerr=dev, fmt='ro', |
| 314 | label=str(conc) + " threads", |
| 315 | color=next(colors_it)) |
| 316 | plt.xlabel("Requested IOPS") |
| 317 | plt.ylabel("Get IOPS") |
| 318 | plt.grid() |
| 319 | plt.legend(loc=0) |
| 320 | plt_iops_vs_requested = get_emb_data_svg(plt) |
| 321 | |
| 322 | res1 = processed_results.values()[0] |
| 323 | params_map = {'iops_vs_lat': plt_iops_vs_lat, |
| 324 | 'iops_vs_requested': plt_iops_vs_requested, |
| 325 | 'oper_descr': get_test_lcheck_params(res1).capitalize()} |
| 326 | |
koder aka kdanilov | 88407ff | 2015-05-26 15:35:57 +0300 | [diff] [blame] | 327 | return get_template('report_iops_vs_lat.html').format(**params_map) |
koder aka kdanilov | 4af1c1d | 2015-05-18 15:48:58 +0300 | [diff] [blame] | 328 | |
| 329 | |
koder aka kdanilov | 88407ff | 2015-05-26 15:35:57 +0300 | [diff] [blame] | 330 | def render_all_html(comment, info, lab_description, images, templ_name): |
koder aka kdanilov | f86d7af | 2015-05-06 04:01:54 +0300 | [diff] [blame] | 331 | data = info.__dict__.copy() |
| 332 | for name, val in data.items(): |
koder aka kdanilov | 209e85d | 2015-04-27 23:11:05 +0300 | [diff] [blame] | 333 | if not name.startswith('__'): |
koder aka kdanilov | c368eb6 | 2015-04-28 18:22:01 +0300 | [diff] [blame] | 334 | if val is None: |
koder aka kdanilov | f86d7af | 2015-05-06 04:01:54 +0300 | [diff] [blame] | 335 | data[name] = '-' |
| 336 | elif isinstance(val, (int, float, long)): |
| 337 | data[name] = round_3_digit(val) |
koder aka kdanilov | 209e85d | 2015-04-27 23:11:05 +0300 | [diff] [blame] | 338 | |
koder aka kdanilov | f86d7af | 2015-05-06 04:01:54 +0300 | [diff] [blame] | 339 | data['bw_read_max'] = (data['bw_read_max'][0] // 1024, |
koder aka kdanilov | c0c97e2 | 2015-07-21 00:08:33 +0300 | [diff] [blame] | 340 | data['bw_read_max'][1], |
| 341 | data['bw_read_max'][2]) |
| 342 | |
koder aka kdanilov | f86d7af | 2015-05-06 04:01:54 +0300 | [diff] [blame] | 343 | data['bw_write_max'] = (data['bw_write_max'][0] // 1024, |
koder aka kdanilov | c0c97e2 | 2015-07-21 00:08:33 +0300 | [diff] [blame] | 344 | data['bw_write_max'][1], |
| 345 | data['bw_write_max'][2]) |
koder aka kdanilov | 7e0f7cf | 2015-05-01 17:24:35 +0300 | [diff] [blame] | 346 | |
koder aka kdanilov | 4af1c1d | 2015-05-18 15:48:58 +0300 | [diff] [blame] | 347 | images.update(data) |
koder aka kdanilov | 88407ff | 2015-05-26 15:35:57 +0300 | [diff] [blame] | 348 | return get_template(templ_name).format(lab_info=lab_description, |
| 349 | comment=comment, |
| 350 | **images) |
koder aka kdanilov | cff7b2e | 2015-04-18 20:48:15 +0300 | [diff] [blame] | 351 | |
| 352 | |
koder aka kdanilov | f86d7af | 2015-05-06 04:01:54 +0300 | [diff] [blame] | 353 | def io_chart(title, concurence, |
| 354 | latv, latv_min, latv_max, |
koder aka kdanilov | 4af1c1d | 2015-05-18 15:48:58 +0300 | [diff] [blame] | 355 | iops_or_bw, iops_or_bw_err, |
koder aka kdanilov | f236b9c | 2015-06-24 18:17:22 +0300 | [diff] [blame] | 356 | legend, |
| 357 | log_iops=False, |
| 358 | log_lat=False, |
koder aka kdanilov | 88407ff | 2015-05-26 15:35:57 +0300 | [diff] [blame] | 359 | boxplots=False, |
koder aka kdanilov | c0c97e2 | 2015-07-21 00:08:33 +0300 | [diff] [blame] | 360 | latv_50=None, |
| 361 | latv_95=None, |
| 362 | error2=None): |
koder aka kdanilov | 0fdaaee | 2015-06-30 11:10:48 +0300 | [diff] [blame] | 363 | |
| 364 | matplotlib.rcParams.update({'font.size': 10}) |
koder aka kdanilov | d5ed4da | 2015-05-07 23:33:23 +0300 | [diff] [blame] | 365 | points = " MiBps" if legend == 'BW' else "" |
| 366 | lc = len(concurence) |
| 367 | width = 0.35 |
| 368 | xt = range(1, lc + 1) |
| 369 | |
koder aka kdanilov | 4af1c1d | 2015-05-18 15:48:58 +0300 | [diff] [blame] | 370 | op_per_vm = [v / (vm * th) for v, (vm, th) in zip(iops_or_bw, concurence)] |
koder aka kdanilov | d5ed4da | 2015-05-07 23:33:23 +0300 | [diff] [blame] | 371 | fig, p1 = plt.subplots() |
| 372 | xpos = [i - width / 2 for i in xt] |
| 373 | |
koder aka kdanilov | 416b87a | 2015-05-12 00:26:04 +0300 | [diff] [blame] | 374 | p1.bar(xpos, iops_or_bw, |
| 375 | width=width, |
koder aka kdanilov | d5ed4da | 2015-05-07 23:33:23 +0300 | [diff] [blame] | 376 | color='y', |
| 377 | label=legend) |
| 378 | |
koder aka kdanilov | c0c97e2 | 2015-07-21 00:08:33 +0300 | [diff] [blame] | 379 | err1_leg = None |
| 380 | for pos, y, err in zip(xpos, iops_or_bw, iops_or_bw_err): |
| 381 | err1_leg = p1.errorbar(pos + width / 2, |
| 382 | y, |
| 383 | err, |
| 384 | color='magenta') |
| 385 | |
| 386 | err2_leg = None |
| 387 | if error2 is not None: |
| 388 | for pos, y, err in zip(xpos, iops_or_bw, error2): |
| 389 | err2_leg = p1.errorbar(pos + width / 2 + 0.08, |
| 390 | y, |
| 391 | err, |
| 392 | lw=2, |
| 393 | alpha=0.5, |
| 394 | color='teal') |
| 395 | |
koder aka kdanilov | d5ed4da | 2015-05-07 23:33:23 +0300 | [diff] [blame] | 396 | p1.grid(True) |
koder aka kdanilov | 4af1c1d | 2015-05-18 15:48:58 +0300 | [diff] [blame] | 397 | p1.plot(xt, op_per_vm, '--', label=legend + "/thread", color='black') |
koder aka kdanilov | 416b87a | 2015-05-12 00:26:04 +0300 | [diff] [blame] | 398 | handles1, labels1 = p1.get_legend_handles_labels() |
koder aka kdanilov | d5ed4da | 2015-05-07 23:33:23 +0300 | [diff] [blame] | 399 | |
koder aka kdanilov | c0c97e2 | 2015-07-21 00:08:33 +0300 | [diff] [blame] | 400 | handles1 += [err1_leg] |
| 401 | labels1 += ["95% conf"] |
| 402 | |
| 403 | if err2_leg is not None: |
| 404 | handles1 += [err2_leg] |
| 405 | labels1 += ["95% dev"] |
| 406 | |
koder aka kdanilov | d5ed4da | 2015-05-07 23:33:23 +0300 | [diff] [blame] | 407 | p2 = p1.twinx() |
koder aka kdanilov | 88407ff | 2015-05-26 15:35:57 +0300 | [diff] [blame] | 408 | |
| 409 | if latv_50 is None: |
| 410 | p2.plot(xt, latv_max, label="lat max") |
| 411 | p2.plot(xt, latv, label="lat avg") |
| 412 | p2.plot(xt, latv_min, label="lat min") |
| 413 | else: |
| 414 | p2.plot(xt, latv_50, label="lat med") |
| 415 | p2.plot(xt, latv_95, label="lat 95%") |
koder aka kdanilov | d5ed4da | 2015-05-07 23:33:23 +0300 | [diff] [blame] | 416 | |
| 417 | plt.xlim(0.5, lc + 0.5) |
koder aka kdanilov | 4af1c1d | 2015-05-18 15:48:58 +0300 | [diff] [blame] | 418 | plt.xticks(xt, ["{0} * {1}".format(vm, th) for (vm, th) in concurence]) |
| 419 | p1.set_xlabel("VM Count * Thread per VM") |
koder aka kdanilov | d5ed4da | 2015-05-07 23:33:23 +0300 | [diff] [blame] | 420 | p1.set_ylabel(legend + points) |
| 421 | p2.set_ylabel("Latency ms") |
| 422 | plt.title(title) |
koder aka kdanilov | 416b87a | 2015-05-12 00:26:04 +0300 | [diff] [blame] | 423 | handles2, labels2 = p2.get_legend_handles_labels() |
| 424 | |
| 425 | plt.legend(handles1 + handles2, labels1 + labels2, |
| 426 | loc='center left', bbox_to_anchor=(1.1, 0.81)) |
koder aka kdanilov | 416b87a | 2015-05-12 00:26:04 +0300 | [diff] [blame] | 427 | |
koder aka kdanilov | f236b9c | 2015-06-24 18:17:22 +0300 | [diff] [blame] | 428 | if log_iops: |
koder aka kdanilov | 416b87a | 2015-05-12 00:26:04 +0300 | [diff] [blame] | 429 | p1.set_yscale('log') |
koder aka kdanilov | f236b9c | 2015-06-24 18:17:22 +0300 | [diff] [blame] | 430 | |
| 431 | if log_lat: |
koder aka kdanilov | 416b87a | 2015-05-12 00:26:04 +0300 | [diff] [blame] | 432 | p2.set_yscale('log') |
koder aka kdanilov | f236b9c | 2015-06-24 18:17:22 +0300 | [diff] [blame] | 433 | |
koder aka kdanilov | 4af1c1d | 2015-05-18 15:48:58 +0300 | [diff] [blame] | 434 | plt.subplots_adjust(right=0.68) |
| 435 | |
| 436 | return get_emb_data_svg(plt) |
koder aka kdanilov | d5ed4da | 2015-05-07 23:33:23 +0300 | [diff] [blame] | 437 | |
| 438 | |
koder aka kdanilov | 4af1c1d | 2015-05-18 15:48:58 +0300 | [diff] [blame] | 439 | def make_plots(processed_results, plots): |
koder aka kdanilov | bb6d6cd | 2015-06-20 02:55:07 +0300 | [diff] [blame] | 440 | """ |
| 441 | processed_results: [PerfInfo] |
| 442 | plots = [(test_name_prefix:str, fname:str, description:str)] |
| 443 | """ |
koder aka kdanilov | 4af1c1d | 2015-05-18 15:48:58 +0300 | [diff] [blame] | 444 | files = {} |
koder aka kdanilov | 63ad206 | 2015-04-27 13:11:40 +0300 | [diff] [blame] | 445 | for name_pref, fname, desc in plots: |
koder aka kdanilov | 4a510ee | 2015-04-21 18:50:42 +0300 | [diff] [blame] | 446 | chart_data = [] |
koder aka kdanilov | 63ad206 | 2015-04-27 13:11:40 +0300 | [diff] [blame] | 447 | |
koder aka kdanilov | bb6d6cd | 2015-06-20 02:55:07 +0300 | [diff] [blame] | 448 | for res in processed_results: |
| 449 | summ = res.name + "_" + res.summary |
| 450 | if summ.startswith(name_pref): |
koder aka kdanilov | 4a510ee | 2015-04-21 18:50:42 +0300 | [diff] [blame] | 451 | chart_data.append(res) |
| 452 | |
koder aka kdanilov | 63ad206 | 2015-04-27 13:11:40 +0300 | [diff] [blame] | 453 | if len(chart_data) == 0: |
| 454 | raise ValueError("Can't found any date for " + name_pref) |
| 455 | |
koder aka kdanilov | 4af1c1d | 2015-05-18 15:48:58 +0300 | [diff] [blame] | 456 | use_bw = ssize2b(chart_data[0].p.blocksize) > 16 * 1024 |
koder aka kdanilov | 63ad206 | 2015-04-27 13:11:40 +0300 | [diff] [blame] | 457 | |
koder aka kdanilov | bb6d6cd | 2015-06-20 02:55:07 +0300 | [diff] [blame] | 458 | chart_data.sort(key=lambda x: x.params['vals']['numjobs']) |
koder aka kdanilov | 4a510ee | 2015-04-21 18:50:42 +0300 | [diff] [blame] | 459 | |
koder aka kdanilov | 88407ff | 2015-05-26 15:35:57 +0300 | [diff] [blame] | 460 | lat = None |
| 461 | lat_min = None |
| 462 | lat_max = None |
koder aka kdanilov | f236b9c | 2015-06-24 18:17:22 +0300 | [diff] [blame] | 463 | |
koder aka kdanilov | 88407ff | 2015-05-26 15:35:57 +0300 | [diff] [blame] | 464 | lat_50 = [x.lat_50 for x in chart_data] |
| 465 | lat_95 = [x.lat_95 for x in chart_data] |
koder aka kdanilov | f86d7af | 2015-05-06 04:01:54 +0300 | [diff] [blame] | 466 | |
koder aka kdanilov | f236b9c | 2015-06-24 18:17:22 +0300 | [diff] [blame] | 467 | lat_diff_max = max(x.lat_95 / x.lat_50 for x in chart_data) |
| 468 | lat_log_scale = (lat_diff_max > 10) |
| 469 | |
koder aka kdanilov | 416b87a | 2015-05-12 00:26:04 +0300 | [diff] [blame] | 470 | testnodes_count = x.testnodes_count |
koder aka kdanilov | 4af1c1d | 2015-05-18 15:48:58 +0300 | [diff] [blame] | 471 | concurence = [(testnodes_count, x.concurence) |
koder aka kdanilov | 416b87a | 2015-05-12 00:26:04 +0300 | [diff] [blame] | 472 | for x in chart_data] |
koder aka kdanilov | 4a510ee | 2015-04-21 18:50:42 +0300 | [diff] [blame] | 473 | |
koder aka kdanilov | 63ad206 | 2015-04-27 13:11:40 +0300 | [diff] [blame] | 474 | if use_bw: |
koder aka kdanilov | f86d7af | 2015-05-06 04:01:54 +0300 | [diff] [blame] | 475 | data = [x.bw.average / 1000 for x in chart_data] |
koder aka kdanilov | c0c97e2 | 2015-07-21 00:08:33 +0300 | [diff] [blame] | 476 | data_conf = [x.bw.confidence / 1000 for x in chart_data] |
| 477 | data_dev = [x.bw.deviation * 2.5 / 1000 for x in chart_data] |
koder aka kdanilov | 63ad206 | 2015-04-27 13:11:40 +0300 | [diff] [blame] | 478 | name = "BW" |
| 479 | else: |
koder aka kdanilov | f86d7af | 2015-05-06 04:01:54 +0300 | [diff] [blame] | 480 | data = [x.iops.average for x in chart_data] |
koder aka kdanilov | c0c97e2 | 2015-07-21 00:08:33 +0300 | [diff] [blame] | 481 | data_conf = [x.iops.confidence for x in chart_data] |
| 482 | data_dev = [x.iops.deviation * 2 for x in chart_data] |
koder aka kdanilov | 63ad206 | 2015-04-27 13:11:40 +0300 | [diff] [blame] | 483 | name = "IOPS" |
| 484 | |
koder aka kdanilov | 4af1c1d | 2015-05-18 15:48:58 +0300 | [diff] [blame] | 485 | fc = io_chart(title=desc, |
| 486 | concurence=concurence, |
koder aka kdanilov | f236b9c | 2015-06-24 18:17:22 +0300 | [diff] [blame] | 487 | |
koder aka kdanilov | bb6d6cd | 2015-06-20 02:55:07 +0300 | [diff] [blame] | 488 | latv=lat, |
| 489 | latv_min=lat_min, |
| 490 | latv_max=lat_max, |
| 491 | |
koder aka kdanilov | 4af1c1d | 2015-05-18 15:48:58 +0300 | [diff] [blame] | 492 | iops_or_bw=data, |
koder aka kdanilov | c0c97e2 | 2015-07-21 00:08:33 +0300 | [diff] [blame] | 493 | iops_or_bw_err=data_conf, |
koder aka kdanilov | bb6d6cd | 2015-06-20 02:55:07 +0300 | [diff] [blame] | 494 | |
| 495 | legend=name, |
koder aka kdanilov | f236b9c | 2015-06-24 18:17:22 +0300 | [diff] [blame] | 496 | log_lat=lat_log_scale, |
koder aka kdanilov | bb6d6cd | 2015-06-20 02:55:07 +0300 | [diff] [blame] | 497 | |
| 498 | latv_50=lat_50, |
koder aka kdanilov | c0c97e2 | 2015-07-21 00:08:33 +0300 | [diff] [blame] | 499 | latv_95=lat_95, |
| 500 | |
| 501 | error2=data_dev) |
koder aka kdanilov | 4af1c1d | 2015-05-18 15:48:58 +0300 | [diff] [blame] | 502 | files[fname] = fc |
| 503 | |
| 504 | return files |
koder aka kdanilov | 4a510ee | 2015-04-21 18:50:42 +0300 | [diff] [blame] | 505 | |
| 506 | |
koder aka kdanilov | 7e0f7cf | 2015-05-01 17:24:35 +0300 | [diff] [blame] | 507 | def find_max_where(processed_results, sync_mode, blocksize, rw, iops=True): |
koder aka kdanilov | f86d7af | 2015-05-06 04:01:54 +0300 | [diff] [blame] | 508 | result = None |
koder aka kdanilov | 7e0f7cf | 2015-05-01 17:24:35 +0300 | [diff] [blame] | 509 | attr = 'iops' if iops else 'bw' |
koder aka kdanilov | bb6d6cd | 2015-06-20 02:55:07 +0300 | [diff] [blame] | 510 | for measurement in processed_results: |
koder aka kdanilov | 4af1c1d | 2015-05-18 15:48:58 +0300 | [diff] [blame] | 511 | ok = measurement.sync_mode == sync_mode |
| 512 | ok = ok and (measurement.p.blocksize == blocksize) |
| 513 | ok = ok and (measurement.p.rw == rw) |
koder aka kdanilov | 7e0f7cf | 2015-05-01 17:24:35 +0300 | [diff] [blame] | 514 | |
| 515 | if ok: |
koder aka kdanilov | f86d7af | 2015-05-06 04:01:54 +0300 | [diff] [blame] | 516 | field = getattr(measurement, attr) |
| 517 | |
| 518 | if result is None: |
| 519 | result = field |
| 520 | elif field.average > result.average: |
| 521 | result = field |
| 522 | |
koder aka kdanilov | 7e0f7cf | 2015-05-01 17:24:35 +0300 | [diff] [blame] | 523 | return result |
| 524 | |
| 525 | |
koder aka kdanilov | 4a510ee | 2015-04-21 18:50:42 +0300 | [diff] [blame] | 526 | def get_disk_info(processed_results): |
| 527 | di = DiskInfo() |
koder aka kdanilov | 7e0f7cf | 2015-05-01 17:24:35 +0300 | [diff] [blame] | 528 | di.direct_iops_w_max = find_max_where(processed_results, |
| 529 | 'd', '4k', 'randwrite') |
| 530 | di.direct_iops_r_max = find_max_where(processed_results, |
| 531 | 'd', '4k', 'randread') |
koder aka kdanilov | f86d7af | 2015-05-06 04:01:54 +0300 | [diff] [blame] | 532 | |
koder aka kdanilov | 88407ff | 2015-05-26 15:35:57 +0300 | [diff] [blame] | 533 | di.direct_iops_w64_max = find_max_where(processed_results, |
| 534 | 'd', '64k', 'randwrite') |
| 535 | |
| 536 | for sz in ('16m', '64m'): |
| 537 | di.bw_write_max = find_max_where(processed_results, |
| 538 | 'd', sz, 'randwrite', False) |
| 539 | if di.bw_write_max is not None: |
| 540 | break |
| 541 | |
koder aka kdanilov | f86d7af | 2015-05-06 04:01:54 +0300 | [diff] [blame] | 542 | if di.bw_write_max is None: |
koder aka kdanilov | 170936a | 2015-06-27 22:51:17 +0300 | [diff] [blame] | 543 | for sz in ('1m', '2m', '4m', '8m'): |
| 544 | di.bw_write_max = find_max_where(processed_results, |
| 545 | 'd', sz, 'write', False) |
| 546 | if di.bw_write_max is not None: |
| 547 | break |
koder aka kdanilov | f86d7af | 2015-05-06 04:01:54 +0300 | [diff] [blame] | 548 | |
koder aka kdanilov | 88407ff | 2015-05-26 15:35:57 +0300 | [diff] [blame] | 549 | for sz in ('16m', '64m'): |
| 550 | di.bw_read_max = find_max_where(processed_results, |
| 551 | 'd', sz, 'randread', False) |
| 552 | if di.bw_read_max is not None: |
| 553 | break |
| 554 | |
koder aka kdanilov | f86d7af | 2015-05-06 04:01:54 +0300 | [diff] [blame] | 555 | if di.bw_read_max is None: |
| 556 | di.bw_read_max = find_max_where(processed_results, |
| 557 | 'd', '1m', 'read', False) |
koder aka kdanilov | 7e0f7cf | 2015-05-01 17:24:35 +0300 | [diff] [blame] | 558 | |
koder aka kdanilov | 88407ff | 2015-05-26 15:35:57 +0300 | [diff] [blame] | 559 | rws4k_iops_lat_th = [] |
koder aka kdanilov | bb6d6cd | 2015-06-20 02:55:07 +0300 | [diff] [blame] | 560 | for res in processed_results: |
koder aka kdanilov | 88407ff | 2015-05-26 15:35:57 +0300 | [diff] [blame] | 561 | if res.sync_mode in 'xs' and res.p.blocksize == '4k': |
koder aka kdanilov | 4af1c1d | 2015-05-18 15:48:58 +0300 | [diff] [blame] | 562 | if res.p.rw != 'randwrite': |
koder aka kdanilov | 4a510ee | 2015-04-21 18:50:42 +0300 | [diff] [blame] | 563 | continue |
koder aka kdanilov | f86d7af | 2015-05-06 04:01:54 +0300 | [diff] [blame] | 564 | rws4k_iops_lat_th.append((res.iops.average, |
koder aka kdanilov | f236b9c | 2015-06-24 18:17:22 +0300 | [diff] [blame] | 565 | res.lat, |
| 566 | # res.lat.average, |
koder aka kdanilov | 4af1c1d | 2015-05-18 15:48:58 +0300 | [diff] [blame] | 567 | res.concurence)) |
koder aka kdanilov | 4a510ee | 2015-04-21 18:50:42 +0300 | [diff] [blame] | 568 | |
koder aka kdanilov | 4a510ee | 2015-04-21 18:50:42 +0300 | [diff] [blame] | 569 | rws4k_iops_lat_th.sort(key=lambda (_1, _2, conc): conc) |
| 570 | |
| 571 | latv = [lat for _, lat, _ in rws4k_iops_lat_th] |
| 572 | |
koder aka kdanilov | 170936a | 2015-06-27 22:51:17 +0300 | [diff] [blame] | 573 | for tlat in [10, 30, 100]: |
koder aka kdanilov | 4a510ee | 2015-04-21 18:50:42 +0300 | [diff] [blame] | 574 | pos = bisect.bisect_left(latv, tlat) |
| 575 | if 0 == pos: |
koder aka kdanilov | 170936a | 2015-06-27 22:51:17 +0300 | [diff] [blame] | 576 | setattr(di, 'rws4k_{}ms'.format(tlat), 0) |
koder aka kdanilov | 4a510ee | 2015-04-21 18:50:42 +0300 | [diff] [blame] | 577 | elif pos == len(latv): |
koder aka kdanilov | bb5fe07 | 2015-05-21 02:50:23 +0300 | [diff] [blame] | 578 | iops3, _, _ = rws4k_iops_lat_th[-1] |
koder aka kdanilov | 0fdaaee | 2015-06-30 11:10:48 +0300 | [diff] [blame] | 579 | iops3 = int(round_3_digit(iops3)) |
koder aka kdanilov | 170936a | 2015-06-27 22:51:17 +0300 | [diff] [blame] | 580 | setattr(di, 'rws4k_{}ms'.format(tlat), ">=" + str(iops3)) |
koder aka kdanilov | 4a510ee | 2015-04-21 18:50:42 +0300 | [diff] [blame] | 581 | else: |
| 582 | lat1 = latv[pos - 1] |
| 583 | lat2 = latv[pos] |
| 584 | |
koder aka kdanilov | f86d7af | 2015-05-06 04:01:54 +0300 | [diff] [blame] | 585 | iops1, _, th1 = rws4k_iops_lat_th[pos - 1] |
| 586 | iops2, _, th2 = rws4k_iops_lat_th[pos] |
koder aka kdanilov | 4a510ee | 2015-04-21 18:50:42 +0300 | [diff] [blame] | 587 | |
| 588 | th_lat_coef = (th2 - th1) / (lat2 - lat1) |
| 589 | th3 = th_lat_coef * (tlat - lat1) + th1 |
| 590 | |
| 591 | th_iops_coef = (iops2 - iops1) / (th2 - th1) |
| 592 | iops3 = th_iops_coef * (th3 - th1) + iops1 |
koder aka kdanilov | 0fdaaee | 2015-06-30 11:10:48 +0300 | [diff] [blame] | 593 | iops3 = int(round_3_digit(iops3)) |
| 594 | setattr(di, 'rws4k_{}ms'.format(tlat), iops3) |
koder aka kdanilov | 4a510ee | 2015-04-21 18:50:42 +0300 | [diff] [blame] | 595 | |
| 596 | hdi = DiskInfo() |
koder aka kdanilov | 7e0f7cf | 2015-05-01 17:24:35 +0300 | [diff] [blame] | 597 | |
| 598 | def pp(x): |
koder aka kdanilov | f86d7af | 2015-05-06 04:01:54 +0300 | [diff] [blame] | 599 | med, conf = x.rounded_average_conf() |
| 600 | conf_perc = int(float(conf) / med * 100) |
koder aka kdanilov | c0c97e2 | 2015-07-21 00:08:33 +0300 | [diff] [blame] | 601 | dev_perc = int(float(x.deviation) / med * 100) |
| 602 | return (round_3_digit(med), conf_perc, dev_perc) |
koder aka kdanilov | 7e0f7cf | 2015-05-01 17:24:35 +0300 | [diff] [blame] | 603 | |
| 604 | hdi.direct_iops_r_max = pp(di.direct_iops_r_max) |
koder aka kdanilov | 88407ff | 2015-05-26 15:35:57 +0300 | [diff] [blame] | 605 | |
| 606 | if di.direct_iops_w_max is not None: |
| 607 | hdi.direct_iops_w_max = pp(di.direct_iops_w_max) |
| 608 | else: |
| 609 | hdi.direct_iops_w_max = None |
| 610 | |
| 611 | if di.direct_iops_w64_max is not None: |
| 612 | hdi.direct_iops_w64_max = pp(di.direct_iops_w64_max) |
| 613 | else: |
| 614 | hdi.direct_iops_w64_max = None |
| 615 | |
koder aka kdanilov | 7e0f7cf | 2015-05-01 17:24:35 +0300 | [diff] [blame] | 616 | hdi.bw_write_max = pp(di.bw_write_max) |
| 617 | hdi.bw_read_max = pp(di.bw_read_max) |
| 618 | |
koder aka kdanilov | c368eb6 | 2015-04-28 18:22:01 +0300 | [diff] [blame] | 619 | hdi.rws4k_10ms = di.rws4k_10ms if 0 != di.rws4k_10ms else None |
| 620 | hdi.rws4k_30ms = di.rws4k_30ms if 0 != di.rws4k_30ms else None |
| 621 | hdi.rws4k_100ms = di.rws4k_100ms if 0 != di.rws4k_100ms else None |
koder aka kdanilov | 4a510ee | 2015-04-21 18:50:42 +0300 | [diff] [blame] | 622 | return hdi |
| 623 | |
| 624 | |
koder aka kdanilov | 88407ff | 2015-05-26 15:35:57 +0300 | [diff] [blame] | 625 | @report('hdd', 'hdd') |
| 626 | def make_hdd_report(processed_results, lab_info, comment): |
koder aka kdanilov | 4af1c1d | 2015-05-18 15:48:58 +0300 | [diff] [blame] | 627 | plots = [ |
koder aka kdanilov | 88407ff | 2015-05-26 15:35:57 +0300 | [diff] [blame] | 628 | ('hdd_rrd4k', 'rand_read_4k', 'Random read 4k direct IOPS'), |
| 629 | ('hdd_rwx4k', 'rand_write_4k', 'Random write 4k sync IOPS') |
koder aka kdanilov | 4af1c1d | 2015-05-18 15:48:58 +0300 | [diff] [blame] | 630 | ] |
koder aka kdanilov | bb6d6cd | 2015-06-20 02:55:07 +0300 | [diff] [blame] | 631 | perf_infos = [res.disk_perf_info() for res in processed_results] |
| 632 | images = make_plots(perf_infos, plots) |
| 633 | di = get_disk_info(perf_infos) |
koder aka kdanilov | 88407ff | 2015-05-26 15:35:57 +0300 | [diff] [blame] | 634 | return render_all_html(comment, di, lab_info, images, "report_hdd.html") |
koder aka kdanilov | 63ad206 | 2015-04-27 13:11:40 +0300 | [diff] [blame] | 635 | |
| 636 | |
koder aka kdanilov | 88407ff | 2015-05-26 15:35:57 +0300 | [diff] [blame] | 637 | @report('cinder_iscsi', 'cinder_iscsi') |
| 638 | def make_cinder_iscsi_report(processed_results, lab_info, comment): |
koder aka kdanilov | 4af1c1d | 2015-05-18 15:48:58 +0300 | [diff] [blame] | 639 | plots = [ |
koder aka kdanilov | 88407ff | 2015-05-26 15:35:57 +0300 | [diff] [blame] | 640 | ('cinder_iscsi_rrd4k', 'rand_read_4k', 'Random read 4k direct IOPS'), |
| 641 | ('cinder_iscsi_rwx4k', 'rand_write_4k', 'Random write 4k sync IOPS') |
| 642 | ] |
koder aka kdanilov | bb6d6cd | 2015-06-20 02:55:07 +0300 | [diff] [blame] | 643 | perf_infos = [res.disk_perf_info() for res in processed_results] |
koder aka kdanilov | 88407ff | 2015-05-26 15:35:57 +0300 | [diff] [blame] | 644 | try: |
koder aka kdanilov | bb6d6cd | 2015-06-20 02:55:07 +0300 | [diff] [blame] | 645 | images = make_plots(perf_infos, plots) |
koder aka kdanilov | 88407ff | 2015-05-26 15:35:57 +0300 | [diff] [blame] | 646 | except ValueError: |
| 647 | plots = [ |
| 648 | ('cinder_iscsi_rrd4k', 'rand_read_4k', 'Random read 4k direct IOPS'), |
| 649 | ('cinder_iscsi_rws4k', 'rand_write_4k', 'Random write 4k sync IOPS') |
| 650 | ] |
koder aka kdanilov | bb6d6cd | 2015-06-20 02:55:07 +0300 | [diff] [blame] | 651 | images = make_plots(perf_infos, plots) |
| 652 | di = get_disk_info(perf_infos) |
koder aka kdanilov | 170936a | 2015-06-27 22:51:17 +0300 | [diff] [blame] | 653 | |
koder aka kdanilov | 88407ff | 2015-05-26 15:35:57 +0300 | [diff] [blame] | 654 | return render_all_html(comment, di, lab_info, images, "report_cinder_iscsi.html") |
| 655 | |
| 656 | |
| 657 | @report('ceph', 'ceph') |
| 658 | def make_ceph_report(processed_results, lab_info, comment): |
| 659 | plots = [ |
| 660 | ('ceph_rrd4k', 'rand_read_4k', 'Random read 4k direct IOPS'), |
| 661 | ('ceph_rws4k', 'rand_write_4k', 'Random write 4k sync IOPS'), |
| 662 | ('ceph_rrd16m', 'rand_read_16m', 'Random read 16m direct MiBps'), |
| 663 | ('ceph_rwd16m', 'rand_write_16m', |
koder aka kdanilov | 4af1c1d | 2015-05-18 15:48:58 +0300 | [diff] [blame] | 664 | 'Random write 16m direct MiBps'), |
| 665 | ] |
| 666 | |
koder aka kdanilov | bb6d6cd | 2015-06-20 02:55:07 +0300 | [diff] [blame] | 667 | perf_infos = [res.disk_perf_info() for res in processed_results] |
| 668 | images = make_plots(perf_infos, plots) |
| 669 | di = get_disk_info(perf_infos) |
koder aka kdanilov | 88407ff | 2015-05-26 15:35:57 +0300 | [diff] [blame] | 670 | return render_all_html(comment, di, lab_info, images, "report_ceph.html") |
koder aka kdanilov | a4a570f | 2015-04-23 22:11:40 +0300 | [diff] [blame] | 671 | |
| 672 | |
koder aka kdanilov | 7248c7b | 2015-05-31 22:53:03 +0300 | [diff] [blame] | 673 | @report('mixed', 'mixed') |
| 674 | def make_mixed_report(processed_results, lab_info, comment): |
| 675 | # |
| 676 | # IOPS(X% read) = 100 / ( X / IOPS_W + (100 - X) / IOPS_R ) |
| 677 | # |
koder aka kdanilov | bb6d6cd | 2015-06-20 02:55:07 +0300 | [diff] [blame] | 678 | |
| 679 | perf_infos = [res.disk_perf_info() for res in processed_results] |
koder aka kdanilov | 7248c7b | 2015-05-31 22:53:03 +0300 | [diff] [blame] | 680 | mixed = collections.defaultdict(lambda: []) |
koder aka kdanilov | bb6d6cd | 2015-06-20 02:55:07 +0300 | [diff] [blame] | 681 | |
| 682 | is_ssd = False |
| 683 | for res in perf_infos: |
koder aka kdanilov | 7248c7b | 2015-05-31 22:53:03 +0300 | [diff] [blame] | 684 | if res.name.startswith('mixed'): |
| 685 | if res.name.startswith('mixed-ssd'): |
| 686 | is_ssd = True |
| 687 | mixed[res.concurence].append((res.p.rwmixread, |
koder aka kdanilov | f236b9c | 2015-06-24 18:17:22 +0300 | [diff] [blame] | 688 | res.lat, |
| 689 | 0, |
| 690 | # res.lat.average / 1000.0, |
| 691 | # res.lat.deviation / 1000.0, |
koder aka kdanilov | 7248c7b | 2015-05-31 22:53:03 +0300 | [diff] [blame] | 692 | res.iops.average, |
| 693 | res.iops.deviation)) |
| 694 | |
| 695 | if len(mixed) == 0: |
| 696 | raise ValueError("No mixed load found") |
| 697 | |
| 698 | fig, p1 = plt.subplots() |
| 699 | p2 = p1.twinx() |
| 700 | |
| 701 | colors = ['red', 'green', 'blue', 'orange', 'magenta', "teal"] |
| 702 | colors_it = iter(colors) |
| 703 | for conc, mix_lat_iops in sorted(mixed.items()): |
| 704 | mix_lat_iops = sorted(mix_lat_iops) |
| 705 | read_perc, lat, dev, iops, iops_dev = zip(*mix_lat_iops) |
| 706 | p1.errorbar(read_perc, iops, color=next(colors_it), |
| 707 | yerr=iops_dev, label=str(conc) + " th") |
| 708 | |
| 709 | p2.errorbar(read_perc, lat, color=next(colors_it), |
| 710 | ls='--', yerr=dev, label=str(conc) + " th lat") |
| 711 | |
| 712 | if is_ssd: |
| 713 | p1.set_yscale('log') |
| 714 | p2.set_yscale('log') |
| 715 | |
| 716 | p1.set_xlim(-5, 105) |
| 717 | |
| 718 | read_perc = set(read_perc) |
| 719 | read_perc.add(0) |
| 720 | read_perc.add(100) |
| 721 | read_perc = sorted(read_perc) |
| 722 | |
| 723 | plt.xticks(read_perc, map(str, read_perc)) |
| 724 | |
| 725 | p1.grid(True) |
| 726 | p1.set_xlabel("% of reads") |
| 727 | p1.set_ylabel("Mixed IOPS") |
| 728 | p2.set_ylabel("Latency, ms") |
| 729 | |
| 730 | handles1, labels1 = p1.get_legend_handles_labels() |
| 731 | handles2, labels2 = p2.get_legend_handles_labels() |
| 732 | plt.subplots_adjust(top=0.85) |
| 733 | plt.legend(handles1 + handles2, labels1 + labels2, |
| 734 | bbox_to_anchor=(0.5, 1.15), |
| 735 | loc='upper center', |
| 736 | prop={'size': 12}, ncol=3) |
| 737 | plt.show() |
| 738 | |
| 739 | |
koder aka kdanilov | 88407ff | 2015-05-26 15:35:57 +0300 | [diff] [blame] | 740 | def make_load_report(idx, results_dir, fname): |
| 741 | dpath = os.path.join(results_dir, "io_" + str(idx)) |
| 742 | files = sorted(os.listdir(dpath)) |
| 743 | gf = lambda x: "_".join(x.rsplit(".", 1)[0].split('_')[:3]) |
| 744 | |
| 745 | for key, group in itertools.groupby(files, gf): |
| 746 | fname = os.path.join(dpath, key + ".fio") |
| 747 | |
| 748 | cfgs = list(parse_all_in_1(open(fname).read(), fname)) |
| 749 | |
| 750 | fname = os.path.join(dpath, key + "_lat.log") |
| 751 | |
| 752 | curr = [] |
| 753 | arrays = [] |
| 754 | |
| 755 | with open(fname) as fd: |
| 756 | for offset, lat, _, _ in csv.reader(fd): |
| 757 | offset = int(offset) |
| 758 | lat = int(lat) |
| 759 | if len(curr) > 0 and curr[-1][0] > offset: |
| 760 | arrays.append(curr) |
| 761 | curr = [] |
| 762 | curr.append((offset, lat)) |
| 763 | arrays.append(curr) |
| 764 | conc = int(cfgs[0].vals.get('numjobs', 1)) |
| 765 | |
| 766 | if conc != 5: |
| 767 | continue |
| 768 | |
| 769 | assert len(arrays) == len(cfgs) * conc |
| 770 | |
| 771 | garrays = [[(0, 0)] for _ in range(conc)] |
| 772 | |
| 773 | for offset in range(len(cfgs)): |
| 774 | for acc, new_arr in zip(garrays, arrays[offset * conc:(offset + 1) * conc]): |
| 775 | last = acc[-1][0] |
| 776 | for off, lat in new_arr: |
| 777 | acc.append((off / 1000. + last, lat / 1000.)) |
| 778 | |
| 779 | for cfg, arr in zip(cfgs, garrays): |
| 780 | plt.plot(*zip(*arr[1:])) |
| 781 | plt.show() |
| 782 | exit(1) |
| 783 | |
| 784 | |
| 785 | def make_io_report(dinfo, comment, path, lab_info=None): |
koder aka kdanilov | f86d7af | 2015-05-06 04:01:54 +0300 | [diff] [blame] | 786 | lab_info = { |
| 787 | "total_disk": "None", |
| 788 | "total_memory": "None", |
| 789 | "nodes_count": "None", |
| 790 | "processor_count": "None" |
| 791 | } |
koder aka kdanilov | cff7b2e | 2015-04-18 20:48:15 +0300 | [diff] [blame] | 792 | |
koder aka kdanilov | a047e1b | 2015-04-21 23:16:59 +0300 | [diff] [blame] | 793 | try: |
koder aka kdanilov | bb6d6cd | 2015-06-20 02:55:07 +0300 | [diff] [blame] | 794 | res_fields = sorted(v.name for v in dinfo) |
koder aka kdanilov | 4af1c1d | 2015-05-18 15:48:58 +0300 | [diff] [blame] | 795 | |
koder aka kdanilov | 88407ff | 2015-05-26 15:35:57 +0300 | [diff] [blame] | 796 | found = False |
koder aka kdanilov | 57ce4db | 2015-04-25 21:25:51 +0300 | [diff] [blame] | 797 | for fields, name, func in report_funcs: |
koder aka kdanilov | afd9874 | 2015-04-24 01:27:22 +0300 | [diff] [blame] | 798 | for field in fields: |
koder aka kdanilov | 57ce4db | 2015-04-25 21:25:51 +0300 | [diff] [blame] | 799 | pos = bisect.bisect_left(res_fields, field) |
| 800 | |
| 801 | if pos == len(res_fields): |
koder aka kdanilov | 63ad206 | 2015-04-27 13:11:40 +0300 | [diff] [blame] | 802 | break |
koder aka kdanilov | 57ce4db | 2015-04-25 21:25:51 +0300 | [diff] [blame] | 803 | |
koder aka kdanilov | be8f89f | 2015-04-28 14:51:51 +0300 | [diff] [blame] | 804 | if not res_fields[pos].startswith(field): |
koder aka kdanilov | afd9874 | 2015-04-24 01:27:22 +0300 | [diff] [blame] | 805 | break |
| 806 | else: |
koder aka kdanilov | 88407ff | 2015-05-26 15:35:57 +0300 | [diff] [blame] | 807 | found = True |
koder aka kdanilov | 57ce4db | 2015-04-25 21:25:51 +0300 | [diff] [blame] | 808 | hpath = path.format(name) |
koder aka kdanilov | 88407ff | 2015-05-26 15:35:57 +0300 | [diff] [blame] | 809 | |
| 810 | try: |
| 811 | report = func(dinfo, lab_info, comment) |
| 812 | except: |
| 813 | logger.exception("Diring {0} report generation".format(name)) |
| 814 | continue |
| 815 | |
koder aka kdanilov | 7248c7b | 2015-05-31 22:53:03 +0300 | [diff] [blame] | 816 | if report is not None: |
| 817 | try: |
| 818 | with open(hpath, "w") as fd: |
| 819 | fd.write(report) |
| 820 | except: |
| 821 | logger.exception("Diring saving {0} report".format(name)) |
| 822 | continue |
| 823 | logger.info("Report {0} saved into {1}".format(name, hpath)) |
| 824 | else: |
| 825 | logger.warning("No report produced by {0!r}".format(name)) |
koder aka kdanilov | 88407ff | 2015-05-26 15:35:57 +0300 | [diff] [blame] | 826 | |
| 827 | if not found: |
koder aka kdanilov | a4a570f | 2015-04-23 22:11:40 +0300 | [diff] [blame] | 828 | logger.warning("No report generator found for this load") |
koder aka kdanilov | afd9874 | 2015-04-24 01:27:22 +0300 | [diff] [blame] | 829 | |
koder aka kdanilov | a047e1b | 2015-04-21 23:16:59 +0300 | [diff] [blame] | 830 | except Exception as exc: |
koder aka kdanilov | 57ce4db | 2015-04-25 21:25:51 +0300 | [diff] [blame] | 831 | import traceback |
| 832 | traceback.print_exc() |
koder aka kdanilov | ec1b973 | 2015-04-23 20:43:29 +0300 | [diff] [blame] | 833 | logger.error("Failed to generate html report:" + str(exc)) |