koder aka kdanilov | cff7b2e | 2015-04-18 20:48:15 +0300 | [diff] [blame] | 1 | import os |
koder aka kdanilov | 4a510ee | 2015-04-21 18:50:42 +0300 | [diff] [blame] | 2 | import bisect |
koder aka kdanilov | a047e1b | 2015-04-21 23:16:59 +0300 | [diff] [blame] | 3 | import logging |
koder aka kdanilov | 416b87a | 2015-05-12 00:26:04 +0300 | [diff] [blame] | 4 | import collections |
koder aka kdanilov | cff7b2e | 2015-04-18 20:48:15 +0300 | [diff] [blame] | 5 | |
koder aka kdanilov | be8f89f | 2015-04-28 14:51:51 +0300 | [diff] [blame] | 6 | try: |
| 7 | import matplotlib.pyplot as plt |
| 8 | except ImportError: |
| 9 | plt = None |
| 10 | |
koder aka kdanilov | 4a510ee | 2015-04-21 18:50:42 +0300 | [diff] [blame] | 11 | import wally |
koder aka kdanilov | cff7b2e | 2015-04-18 20:48:15 +0300 | [diff] [blame] | 12 | from wally import charts |
koder aka kdanilov | f86d7af | 2015-05-06 04:01:54 +0300 | [diff] [blame] | 13 | from wally.utils import ssize2b |
| 14 | from wally.statistic import round_3_digit, data_property |
koder aka kdanilov | cff7b2e | 2015-04-18 20:48:15 +0300 | [diff] [blame] | 15 | |
koder aka kdanilov | 4a510ee | 2015-04-21 18:50:42 +0300 | [diff] [blame] | 16 | |
koder aka kdanilov | a047e1b | 2015-04-21 23:16:59 +0300 | [diff] [blame] | 17 | logger = logging.getLogger("wally.report") |
| 18 | |
| 19 | |
koder aka kdanilov | 209e85d | 2015-04-27 23:11:05 +0300 | [diff] [blame] | 20 | class DiskInfo(object): |
| 21 | def __init__(self): |
| 22 | self.direct_iops_r_max = 0 |
| 23 | self.direct_iops_w_max = 0 |
| 24 | self.rws4k_10ms = 0 |
| 25 | self.rws4k_30ms = 0 |
| 26 | self.rws4k_100ms = 0 |
| 27 | self.bw_write_max = 0 |
| 28 | self.bw_read_max = 0 |
| 29 | |
| 30 | |
koder aka kdanilov | be8f89f | 2015-04-28 14:51:51 +0300 | [diff] [blame] | 31 | report_funcs = [] |
| 32 | |
| 33 | |
koder aka kdanilov | f86d7af | 2015-05-06 04:01:54 +0300 | [diff] [blame] | 34 | class PerfInfo(object): |
koder aka kdanilov | 416b87a | 2015-05-12 00:26:04 +0300 | [diff] [blame] | 35 | def __init__(self, name, intervals, params, testnodes_count): |
koder aka kdanilov | f86d7af | 2015-05-06 04:01:54 +0300 | [diff] [blame] | 36 | self.name = name |
| 37 | self.bw = None |
| 38 | self.iops = None |
| 39 | self.lat = None |
koder aka kdanilov | 416b87a | 2015-05-12 00:26:04 +0300 | [diff] [blame] | 40 | self.params = params |
| 41 | self.intervals = intervals |
| 42 | self.testnodes_count = testnodes_count |
koder aka kdanilov | f86d7af | 2015-05-06 04:01:54 +0300 | [diff] [blame] | 43 | |
| 44 | |
| 45 | def split_and_add(data, block_size): |
| 46 | assert len(data) % block_size == 0 |
| 47 | res = [0] * block_size |
| 48 | |
| 49 | for idx, val in enumerate(data): |
| 50 | res[idx % block_size] += val |
| 51 | |
| 52 | return res |
| 53 | |
| 54 | |
koder aka kdanilov | 416b87a | 2015-05-12 00:26:04 +0300 | [diff] [blame] | 55 | def group_by_name(test_data): |
| 56 | name_map = collections.defaultdict(lambda: []) |
| 57 | |
| 58 | for block in test_data: |
| 59 | for data in block['res']: |
| 60 | data = data.copy() |
| 61 | data['__meta__'] = block['__meta__'] |
| 62 | name_map[data['name']].append(data) |
| 63 | |
| 64 | return name_map |
| 65 | |
| 66 | |
koder aka kdanilov | f86d7af | 2015-05-06 04:01:54 +0300 | [diff] [blame] | 67 | def process_disk_info(test_data): |
koder aka kdanilov | 416b87a | 2015-05-12 00:26:04 +0300 | [diff] [blame] | 68 | name_map = group_by_name(test_data) |
koder aka kdanilov | f86d7af | 2015-05-06 04:01:54 +0300 | [diff] [blame] | 69 | data = {} |
koder aka kdanilov | 416b87a | 2015-05-12 00:26:04 +0300 | [diff] [blame] | 70 | for name, results in name_map.items(): |
| 71 | testnodes_count_set = set(dt['__meta__']['testnodes_count'] |
| 72 | for dt in results) |
koder aka kdanilov | f86d7af | 2015-05-06 04:01:54 +0300 | [diff] [blame] | 73 | |
koder aka kdanilov | 416b87a | 2015-05-12 00:26:04 +0300 | [diff] [blame] | 74 | assert len(testnodes_count_set) == 1 |
| 75 | testnodes_count, = testnodes_count_set |
| 76 | assert len(results) % testnodes_count == 0 |
koder aka kdanilov | f86d7af | 2015-05-06 04:01:54 +0300 | [diff] [blame] | 77 | |
koder aka kdanilov | 416b87a | 2015-05-12 00:26:04 +0300 | [diff] [blame] | 78 | block_count = len(results) // testnodes_count |
| 79 | intervals = [result['run_interval'] for result in results] |
| 80 | |
| 81 | p = results[0]['params'].copy() |
| 82 | rt = p.pop('ramp_time', 0) |
| 83 | |
| 84 | for result in results[1:]: |
| 85 | tp = result['params'].copy() |
| 86 | tp.pop('ramp_time', None) |
| 87 | assert tp == p |
| 88 | |
| 89 | p['ramp_time'] = rt |
| 90 | pinfo = PerfInfo(name, intervals, p, testnodes_count) |
| 91 | |
| 92 | bw = [result['results']['bw'] for result in results] |
| 93 | iops = [result['results']['iops'] for result in results] |
| 94 | lat = [result['results']['lat'] for result in results] |
| 95 | |
| 96 | pinfo.bw = data_property(split_and_add(bw, block_count)) |
| 97 | pinfo.iops = data_property(split_and_add(iops, block_count)) |
| 98 | pinfo.lat = data_property(lat) |
| 99 | |
koder aka kdanilov | f86d7af | 2015-05-06 04:01:54 +0300 | [diff] [blame] | 100 | data[name] = pinfo |
| 101 | return data |
| 102 | |
| 103 | |
koder aka kdanilov | be8f89f | 2015-04-28 14:51:51 +0300 | [diff] [blame] | 104 | def report(name, required_fields): |
| 105 | def closure(func): |
| 106 | report_funcs.append((required_fields.split(","), name, func)) |
| 107 | return func |
| 108 | return closure |
| 109 | |
| 110 | |
koder aka kdanilov | 63e9c5a | 2015-04-28 23:06:07 +0300 | [diff] [blame] | 111 | def linearity_report(processed_results, path, lab_info): |
| 112 | names = {} |
| 113 | for tp1 in ('rand', 'seq'): |
| 114 | for oper in ('read', 'write'): |
| 115 | for sync in ('sync', 'direct', 'async'): |
| 116 | sq = (tp1, oper, sync) |
| 117 | name = "{0} {1} {2}".format(*sq) |
| 118 | names["".join(word[0] for word in sq)] = name |
koder aka kdanilov | be8f89f | 2015-04-28 14:51:51 +0300 | [diff] [blame] | 119 | |
koder aka kdanilov | 63e9c5a | 2015-04-28 23:06:07 +0300 | [diff] [blame] | 120 | colors = ['red', 'green', 'blue', 'cyan', |
| 121 | 'magenta', 'black', 'yellow', 'burlywood'] |
| 122 | markers = ['*', '^', 'x', 'o', '+', '.'] |
| 123 | color = 0 |
| 124 | marker = 0 |
koder aka kdanilov | be8f89f | 2015-04-28 14:51:51 +0300 | [diff] [blame] | 125 | |
koder aka kdanilov | 63e9c5a | 2015-04-28 23:06:07 +0300 | [diff] [blame] | 126 | plot_data = {} |
koder aka kdanilov | be8f89f | 2015-04-28 14:51:51 +0300 | [diff] [blame] | 127 | |
koder aka kdanilov | 63e9c5a | 2015-04-28 23:06:07 +0300 | [diff] [blame] | 128 | name_pref = 'linearity_test_rrd' |
koder aka kdanilov | be8f89f | 2015-04-28 14:51:51 +0300 | [diff] [blame] | 129 | |
koder aka kdanilov | 63e9c5a | 2015-04-28 23:06:07 +0300 | [diff] [blame] | 130 | for res in processed_results.values(): |
| 131 | if res.name.startswith(name_pref): |
| 132 | iotime = 1000000. / res.iops |
| 133 | iotime_max = iotime * (1 + res.dev * 3) |
koder aka kdanilov | f86d7af | 2015-05-06 04:01:54 +0300 | [diff] [blame] | 134 | bsize = ssize2b(res.raw['blocksize']) |
koder aka kdanilov | 63e9c5a | 2015-04-28 23:06:07 +0300 | [diff] [blame] | 135 | plot_data[bsize] = (iotime, iotime_max) |
koder aka kdanilov | be8f89f | 2015-04-28 14:51:51 +0300 | [diff] [blame] | 136 | |
koder aka kdanilov | 63e9c5a | 2015-04-28 23:06:07 +0300 | [diff] [blame] | 137 | min_sz = min(plot_data) |
| 138 | min_iotime, _ = plot_data.pop(min_sz) |
koder aka kdanilov | be8f89f | 2015-04-28 14:51:51 +0300 | [diff] [blame] | 139 | |
koder aka kdanilov | 63e9c5a | 2015-04-28 23:06:07 +0300 | [diff] [blame] | 140 | x = [] |
| 141 | y = [] |
| 142 | e = [] |
koder aka kdanilov | be8f89f | 2015-04-28 14:51:51 +0300 | [diff] [blame] | 143 | |
koder aka kdanilov | 63e9c5a | 2015-04-28 23:06:07 +0300 | [diff] [blame] | 144 | for k, (v, vmax) in sorted(plot_data.items()): |
koder aka kdanilov | 63e9c5a | 2015-04-28 23:06:07 +0300 | [diff] [blame] | 145 | y.append(v - min_iotime) |
| 146 | x.append(k) |
| 147 | e.append(y[-1] - (vmax - min_iotime)) |
| 148 | |
koder aka kdanilov | 63e9c5a | 2015-04-28 23:06:07 +0300 | [diff] [blame] | 149 | tp = 'rrd' |
| 150 | plt.errorbar(x, y, e, linestyle='None', label=names[tp], |
| 151 | color=colors[color], ecolor="black", |
| 152 | marker=markers[marker]) |
| 153 | plt.yscale('log') |
| 154 | plt.xscale('log') |
koder aka kdanilov | f86d7af | 2015-05-06 04:01:54 +0300 | [diff] [blame] | 155 | # plt.show() |
koder aka kdanilov | 63e9c5a | 2015-04-28 23:06:07 +0300 | [diff] [blame] | 156 | |
| 157 | # ynew = approximate_line(ax, ay, ax, True) |
| 158 | # plt.plot(ax, ynew, color=colors[color]) |
| 159 | # color += 1 |
| 160 | # marker += 1 |
| 161 | # plt.legend(loc=2) |
| 162 | # plt.title("Linearity test by %i dots" % (len(vals))) |
| 163 | |
| 164 | |
| 165 | if plt: |
| 166 | linearity_report = report('linearity', 'linearity_test')(linearity_report) |
koder aka kdanilov | be8f89f | 2015-04-28 14:51:51 +0300 | [diff] [blame] | 167 | |
| 168 | |
koder aka kdanilov | d5ed4da | 2015-05-07 23:33:23 +0300 | [diff] [blame] | 169 | def render_all_html(dest, info, lab_description, img_ext, templ_name): |
koder aka kdanilov | 4a510ee | 2015-04-21 18:50:42 +0300 | [diff] [blame] | 170 | very_root_dir = os.path.dirname(os.path.dirname(wally.__file__)) |
| 171 | templ_dir = os.path.join(very_root_dir, 'report_templates') |
koder aka kdanilov | f86d7af | 2015-05-06 04:01:54 +0300 | [diff] [blame] | 172 | templ_file = os.path.join(templ_dir, templ_name) |
koder aka kdanilov | 63ad206 | 2015-04-27 13:11:40 +0300 | [diff] [blame] | 173 | templ = open(templ_file, 'r').read() |
koder aka kdanilov | 209e85d | 2015-04-27 23:11:05 +0300 | [diff] [blame] | 174 | |
koder aka kdanilov | f86d7af | 2015-05-06 04:01:54 +0300 | [diff] [blame] | 175 | data = info.__dict__.copy() |
| 176 | for name, val in data.items(): |
koder aka kdanilov | 209e85d | 2015-04-27 23:11:05 +0300 | [diff] [blame] | 177 | if not name.startswith('__'): |
koder aka kdanilov | c368eb6 | 2015-04-28 18:22:01 +0300 | [diff] [blame] | 178 | if val is None: |
koder aka kdanilov | f86d7af | 2015-05-06 04:01:54 +0300 | [diff] [blame] | 179 | data[name] = '-' |
| 180 | elif isinstance(val, (int, float, long)): |
| 181 | data[name] = round_3_digit(val) |
koder aka kdanilov | 209e85d | 2015-04-27 23:11:05 +0300 | [diff] [blame] | 182 | |
koder aka kdanilov | f86d7af | 2015-05-06 04:01:54 +0300 | [diff] [blame] | 183 | data['bw_read_max'] = (data['bw_read_max'][0] // 1024, |
| 184 | data['bw_read_max'][1]) |
| 185 | data['bw_write_max'] = (data['bw_write_max'][0] // 1024, |
| 186 | data['bw_write_max'][1]) |
koder aka kdanilov | 7e0f7cf | 2015-05-01 17:24:35 +0300 | [diff] [blame] | 187 | |
koder aka kdanilov | d5ed4da | 2015-05-07 23:33:23 +0300 | [diff] [blame] | 188 | report = templ.format(lab_info=lab_description, img_ext=img_ext, |
| 189 | **data) |
koder aka kdanilov | 63ad206 | 2015-04-27 13:11:40 +0300 | [diff] [blame] | 190 | open(dest, 'w').write(report) |
| 191 | |
| 192 | |
koder aka kdanilov | d5ed4da | 2015-05-07 23:33:23 +0300 | [diff] [blame] | 193 | def render_hdd_html(dest, info, lab_description, img_ext): |
| 194 | render_all_html(dest, info, lab_description, img_ext, |
| 195 | "report_hdd.html") |
koder aka kdanilov | f86d7af | 2015-05-06 04:01:54 +0300 | [diff] [blame] | 196 | |
| 197 | |
koder aka kdanilov | d5ed4da | 2015-05-07 23:33:23 +0300 | [diff] [blame] | 198 | def render_ceph_html(dest, info, lab_description, img_ext): |
| 199 | render_all_html(dest, info, lab_description, img_ext, |
| 200 | "report_ceph.html") |
koder aka kdanilov | cff7b2e | 2015-04-18 20:48:15 +0300 | [diff] [blame] | 201 | |
| 202 | |
koder aka kdanilov | f86d7af | 2015-05-06 04:01:54 +0300 | [diff] [blame] | 203 | def io_chart(title, concurence, |
| 204 | latv, latv_min, latv_max, |
| 205 | iops_or_bw, iops_or_bw_dev, |
koder aka kdanilov | cff7b2e | 2015-04-18 20:48:15 +0300 | [diff] [blame] | 206 | legend, fname): |
koder aka kdanilov | f86d7af | 2015-05-06 04:01:54 +0300 | [diff] [blame] | 207 | bar_data = iops_or_bw |
| 208 | bar_dev = iops_or_bw_dev |
koder aka kdanilov | cff7b2e | 2015-04-18 20:48:15 +0300 | [diff] [blame] | 209 | legend = [legend] |
| 210 | |
| 211 | iops_or_bw_per_vm = [] |
koder aka kdanilov | d5ed4da | 2015-05-07 23:33:23 +0300 | [diff] [blame] | 212 | for iops, conc in zip(iops_or_bw, concurence): |
| 213 | iops_or_bw_per_vm.append(iops / conc) |
koder aka kdanilov | cff7b2e | 2015-04-18 20:48:15 +0300 | [diff] [blame] | 214 | |
| 215 | bar_dev_bottom = [] |
| 216 | bar_dev_top = [] |
koder aka kdanilov | d5ed4da | 2015-05-07 23:33:23 +0300 | [diff] [blame] | 217 | for val, err in zip(bar_data, bar_dev): |
| 218 | bar_dev_top.append(val + err) |
| 219 | bar_dev_bottom.append(val - err) |
koder aka kdanilov | cff7b2e | 2015-04-18 20:48:15 +0300 | [diff] [blame] | 220 | |
koder aka kdanilov | d5ed4da | 2015-05-07 23:33:23 +0300 | [diff] [blame] | 221 | charts.render_vertical_bar(title, legend, [bar_data], [bar_dev_top], |
| 222 | [bar_dev_bottom], file_name=fname, |
| 223 | scale_x=concurence, label_x="clients", |
| 224 | label_y=legend[0], |
| 225 | lines=[ |
| 226 | (latv, "msec", "rr", "lat"), |
| 227 | # (latv_min, None, None, "lat_min"), |
| 228 | # (latv_max, None, None, "lat_max"), |
| 229 | (iops_or_bw_per_vm, None, None, |
| 230 | legend[0] + " per client") |
| 231 | ]) |
koder aka kdanilov | cff7b2e | 2015-04-18 20:48:15 +0300 | [diff] [blame] | 232 | |
| 233 | |
koder aka kdanilov | d5ed4da | 2015-05-07 23:33:23 +0300 | [diff] [blame] | 234 | def io_chart_mpl(title, concurence, |
| 235 | latv, latv_min, latv_max, |
| 236 | iops_or_bw, iops_or_bw_err, |
koder aka kdanilov | 416b87a | 2015-05-12 00:26:04 +0300 | [diff] [blame] | 237 | legend, fname, log=False): |
koder aka kdanilov | d5ed4da | 2015-05-07 23:33:23 +0300 | [diff] [blame] | 238 | points = " MiBps" if legend == 'BW' else "" |
| 239 | lc = len(concurence) |
| 240 | width = 0.35 |
| 241 | xt = range(1, lc + 1) |
| 242 | |
| 243 | op_per_vm = [v / c for v, c in zip(iops_or_bw, concurence)] |
| 244 | fig, p1 = plt.subplots() |
| 245 | xpos = [i - width / 2 for i in xt] |
| 246 | |
koder aka kdanilov | 416b87a | 2015-05-12 00:26:04 +0300 | [diff] [blame] | 247 | p1.bar(xpos, iops_or_bw, |
| 248 | width=width, |
| 249 | yerr=iops_or_bw_err, |
| 250 | ecolor='m', |
koder aka kdanilov | d5ed4da | 2015-05-07 23:33:23 +0300 | [diff] [blame] | 251 | color='y', |
| 252 | label=legend) |
| 253 | |
koder aka kdanilov | d5ed4da | 2015-05-07 23:33:23 +0300 | [diff] [blame] | 254 | p1.grid(True) |
koder aka kdanilov | 416b87a | 2015-05-12 00:26:04 +0300 | [diff] [blame] | 255 | p1.plot(xt, op_per_vm, '--', label=legend + "/vm", color='black') |
| 256 | handles1, labels1 = p1.get_legend_handles_labels() |
koder aka kdanilov | d5ed4da | 2015-05-07 23:33:23 +0300 | [diff] [blame] | 257 | |
| 258 | p2 = p1.twinx() |
koder aka kdanilov | 416b87a | 2015-05-12 00:26:04 +0300 | [diff] [blame] | 259 | p2.plot(xt, latv_max, label="lat max") |
| 260 | p2.plot(xt, latv, label="lat avg") |
| 261 | p2.plot(xt, latv_min, label="lat min") |
koder aka kdanilov | d5ed4da | 2015-05-07 23:33:23 +0300 | [diff] [blame] | 262 | |
| 263 | plt.xlim(0.5, lc + 0.5) |
| 264 | plt.xticks(xt, map(str, concurence)) |
| 265 | p1.set_xlabel("Threads") |
| 266 | p1.set_ylabel(legend + points) |
| 267 | p2.set_ylabel("Latency ms") |
| 268 | plt.title(title) |
koder aka kdanilov | 416b87a | 2015-05-12 00:26:04 +0300 | [diff] [blame] | 269 | handles2, labels2 = p2.get_legend_handles_labels() |
| 270 | |
| 271 | plt.legend(handles1 + handles2, labels1 + labels2, |
| 272 | loc='center left', bbox_to_anchor=(1.1, 0.81)) |
| 273 | # fontsize='small') |
| 274 | |
| 275 | if log: |
| 276 | p1.set_yscale('log') |
| 277 | p2.set_yscale('log') |
| 278 | plt.subplots_adjust(right=0.7) |
| 279 | # plt.show() # bbox_extra_artists=(leg,), bbox_inches='tight') |
| 280 | # exit(1) |
koder aka kdanilov | d5ed4da | 2015-05-07 23:33:23 +0300 | [diff] [blame] | 281 | plt.savefig(fname, format=fname.split('.')[-1]) |
| 282 | |
| 283 | |
| 284 | def make_hdd_plots(processed_results, charts_dir): |
koder aka kdanilov | 63ad206 | 2015-04-27 13:11:40 +0300 | [diff] [blame] | 285 | plots = [ |
| 286 | ('hdd_test_rrd4k', 'rand_read_4k', 'Random read 4k direct IOPS'), |
koder aka kdanilov | ea7eac7 | 2015-04-21 21:37:27 +0300 | [diff] [blame] | 287 | ('hdd_test_rws4k', 'rand_write_4k', 'Random write 4k sync IOPS') |
koder aka kdanilov | 4a510ee | 2015-04-21 18:50:42 +0300 | [diff] [blame] | 288 | ] |
koder aka kdanilov | d5ed4da | 2015-05-07 23:33:23 +0300 | [diff] [blame] | 289 | return make_plots(processed_results, charts_dir, plots) |
koder aka kdanilov | 4a510ee | 2015-04-21 18:50:42 +0300 | [diff] [blame] | 290 | |
koder aka kdanilov | 63ad206 | 2015-04-27 13:11:40 +0300 | [diff] [blame] | 291 | |
koder aka kdanilov | d5ed4da | 2015-05-07 23:33:23 +0300 | [diff] [blame] | 292 | def make_ceph_plots(processed_results, charts_dir): |
koder aka kdanilov | 63ad206 | 2015-04-27 13:11:40 +0300 | [diff] [blame] | 293 | plots = [ |
| 294 | ('ceph_test_rrd4k', 'rand_read_4k', 'Random read 4k direct IOPS'), |
| 295 | ('ceph_test_rws4k', 'rand_write_4k', 'Random write 4k sync IOPS'), |
koder aka kdanilov | d5ed4da | 2015-05-07 23:33:23 +0300 | [diff] [blame] | 296 | ('ceph_test_rrd16m', 'rand_read_16m', |
| 297 | 'Random read 16m direct MiBps'), |
koder aka kdanilov | 7e0f7cf | 2015-05-01 17:24:35 +0300 | [diff] [blame] | 298 | ('ceph_test_rwd16m', 'rand_write_16m', |
| 299 | 'Random write 16m direct MiBps'), |
koder aka kdanilov | 63ad206 | 2015-04-27 13:11:40 +0300 | [diff] [blame] | 300 | ] |
koder aka kdanilov | d5ed4da | 2015-05-07 23:33:23 +0300 | [diff] [blame] | 301 | return make_plots(processed_results, charts_dir, plots) |
koder aka kdanilov | 63ad206 | 2015-04-27 13:11:40 +0300 | [diff] [blame] | 302 | |
| 303 | |
koder aka kdanilov | d5ed4da | 2015-05-07 23:33:23 +0300 | [diff] [blame] | 304 | def make_plots(processed_results, charts_dir, plots): |
| 305 | file_ext = None |
koder aka kdanilov | 63ad206 | 2015-04-27 13:11:40 +0300 | [diff] [blame] | 306 | for name_pref, fname, desc in plots: |
koder aka kdanilov | 4a510ee | 2015-04-21 18:50:42 +0300 | [diff] [blame] | 307 | chart_data = [] |
koder aka kdanilov | 63ad206 | 2015-04-27 13:11:40 +0300 | [diff] [blame] | 308 | |
koder aka kdanilov | 4a510ee | 2015-04-21 18:50:42 +0300 | [diff] [blame] | 309 | for res in processed_results.values(): |
| 310 | if res.name.startswith(name_pref): |
| 311 | chart_data.append(res) |
| 312 | |
koder aka kdanilov | 63ad206 | 2015-04-27 13:11:40 +0300 | [diff] [blame] | 313 | if len(chart_data) == 0: |
| 314 | raise ValueError("Can't found any date for " + name_pref) |
| 315 | |
koder aka kdanilov | 416b87a | 2015-05-12 00:26:04 +0300 | [diff] [blame] | 316 | use_bw = ssize2b(chart_data[0].params['blocksize']) > 16 * 1024 |
koder aka kdanilov | 63ad206 | 2015-04-27 13:11:40 +0300 | [diff] [blame] | 317 | |
koder aka kdanilov | 416b87a | 2015-05-12 00:26:04 +0300 | [diff] [blame] | 318 | chart_data.sort(key=lambda x: x.params['concurence']) |
koder aka kdanilov | 4a510ee | 2015-04-21 18:50:42 +0300 | [diff] [blame] | 319 | |
koder aka kdanilov | f86d7af | 2015-05-06 04:01:54 +0300 | [diff] [blame] | 320 | # if x.lat.average < max_lat] |
| 321 | lat = [x.lat.average / 1000 for x in chart_data] |
koder aka kdanilov | d5ed4da | 2015-05-07 23:33:23 +0300 | [diff] [blame] | 322 | lat_min = [x.lat.min / 1000 for x in chart_data] |
| 323 | lat_max = [x.lat.max / 1000 for x in chart_data] |
koder aka kdanilov | f86d7af | 2015-05-06 04:01:54 +0300 | [diff] [blame] | 324 | |
koder aka kdanilov | 416b87a | 2015-05-12 00:26:04 +0300 | [diff] [blame] | 325 | testnodes_count = x.testnodes_count |
| 326 | concurence = [x.params['concurence'] * testnodes_count |
| 327 | for x in chart_data] |
koder aka kdanilov | 4a510ee | 2015-04-21 18:50:42 +0300 | [diff] [blame] | 328 | |
koder aka kdanilov | 63ad206 | 2015-04-27 13:11:40 +0300 | [diff] [blame] | 329 | if use_bw: |
koder aka kdanilov | f86d7af | 2015-05-06 04:01:54 +0300 | [diff] [blame] | 330 | data = [x.bw.average / 1000 for x in chart_data] |
| 331 | data_dev = [x.bw.confidence / 1000 for x in chart_data] |
koder aka kdanilov | 63ad206 | 2015-04-27 13:11:40 +0300 | [diff] [blame] | 332 | name = "BW" |
| 333 | else: |
koder aka kdanilov | f86d7af | 2015-05-06 04:01:54 +0300 | [diff] [blame] | 334 | data = [x.iops.average for x in chart_data] |
| 335 | data_dev = [x.iops.confidence for x in chart_data] |
koder aka kdanilov | 63ad206 | 2015-04-27 13:11:40 +0300 | [diff] [blame] | 336 | name = "IOPS" |
| 337 | |
koder aka kdanilov | d5ed4da | 2015-05-07 23:33:23 +0300 | [diff] [blame] | 338 | fname = os.path.join(charts_dir, fname) |
| 339 | if plt is not None: |
| 340 | io_chart_mpl(desc, concurence, lat, lat_min, lat_max, |
| 341 | data, data_dev, name, fname + '.svg') |
| 342 | file_ext = 'svg' |
| 343 | else: |
| 344 | io_chart(desc, concurence, lat, lat_min, lat_max, |
| 345 | data, data_dev, name, fname + '.png') |
| 346 | file_ext = 'png' |
| 347 | return file_ext |
koder aka kdanilov | 4a510ee | 2015-04-21 18:50:42 +0300 | [diff] [blame] | 348 | |
| 349 | |
koder aka kdanilov | 7e0f7cf | 2015-05-01 17:24:35 +0300 | [diff] [blame] | 350 | 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] | 351 | result = None |
koder aka kdanilov | 7e0f7cf | 2015-05-01 17:24:35 +0300 | [diff] [blame] | 352 | attr = 'iops' if iops else 'bw' |
| 353 | for measurement in processed_results.values(): |
koder aka kdanilov | 416b87a | 2015-05-12 00:26:04 +0300 | [diff] [blame] | 354 | ok = measurement.params['sync_mode'] == sync_mode |
| 355 | ok = ok and (measurement.params['blocksize'] == blocksize) |
| 356 | ok = ok and (measurement.params['rw'] == rw) |
koder aka kdanilov | 7e0f7cf | 2015-05-01 17:24:35 +0300 | [diff] [blame] | 357 | |
| 358 | if ok: |
koder aka kdanilov | f86d7af | 2015-05-06 04:01:54 +0300 | [diff] [blame] | 359 | field = getattr(measurement, attr) |
| 360 | |
| 361 | if result is None: |
| 362 | result = field |
| 363 | elif field.average > result.average: |
| 364 | result = field |
| 365 | |
koder aka kdanilov | 7e0f7cf | 2015-05-01 17:24:35 +0300 | [diff] [blame] | 366 | return result |
| 367 | |
| 368 | |
koder aka kdanilov | 4a510ee | 2015-04-21 18:50:42 +0300 | [diff] [blame] | 369 | def get_disk_info(processed_results): |
| 370 | di = DiskInfo() |
| 371 | rws4k_iops_lat_th = [] |
| 372 | |
koder aka kdanilov | 7e0f7cf | 2015-05-01 17:24:35 +0300 | [diff] [blame] | 373 | di.direct_iops_w_max = find_max_where(processed_results, |
| 374 | 'd', '4k', 'randwrite') |
| 375 | di.direct_iops_r_max = find_max_where(processed_results, |
| 376 | 'd', '4k', 'randread') |
koder aka kdanilov | f86d7af | 2015-05-06 04:01:54 +0300 | [diff] [blame] | 377 | |
koder aka kdanilov | 7e0f7cf | 2015-05-01 17:24:35 +0300 | [diff] [blame] | 378 | di.bw_write_max = find_max_where(processed_results, |
| 379 | 'd', '16m', 'randwrite', False) |
koder aka kdanilov | f86d7af | 2015-05-06 04:01:54 +0300 | [diff] [blame] | 380 | if di.bw_write_max is None: |
| 381 | di.bw_write_max = find_max_where(processed_results, |
| 382 | 'd', '1m', 'write', False) |
| 383 | |
koder aka kdanilov | 7e0f7cf | 2015-05-01 17:24:35 +0300 | [diff] [blame] | 384 | di.bw_read_max = find_max_where(processed_results, |
| 385 | 'd', '16m', 'randread', False) |
koder aka kdanilov | f86d7af | 2015-05-06 04:01:54 +0300 | [diff] [blame] | 386 | if di.bw_read_max is None: |
| 387 | di.bw_read_max = find_max_where(processed_results, |
| 388 | 'd', '1m', 'read', False) |
koder aka kdanilov | 7e0f7cf | 2015-05-01 17:24:35 +0300 | [diff] [blame] | 389 | |
koder aka kdanilov | 4a510ee | 2015-04-21 18:50:42 +0300 | [diff] [blame] | 390 | for res in processed_results.values(): |
koder aka kdanilov | 416b87a | 2015-05-12 00:26:04 +0300 | [diff] [blame] | 391 | if res.params['sync_mode'] == 's' and res.params['blocksize'] == '4k': |
| 392 | if res.params['rw'] != 'randwrite': |
koder aka kdanilov | 4a510ee | 2015-04-21 18:50:42 +0300 | [diff] [blame] | 393 | continue |
koder aka kdanilov | f86d7af | 2015-05-06 04:01:54 +0300 | [diff] [blame] | 394 | rws4k_iops_lat_th.append((res.iops.average, |
| 395 | res.lat.average, |
koder aka kdanilov | 416b87a | 2015-05-12 00:26:04 +0300 | [diff] [blame] | 396 | res.params['concurence'])) |
koder aka kdanilov | 4a510ee | 2015-04-21 18:50:42 +0300 | [diff] [blame] | 397 | |
koder aka kdanilov | 4a510ee | 2015-04-21 18:50:42 +0300 | [diff] [blame] | 398 | rws4k_iops_lat_th.sort(key=lambda (_1, _2, conc): conc) |
| 399 | |
| 400 | latv = [lat for _, lat, _ in rws4k_iops_lat_th] |
| 401 | |
| 402 | for tlatv_ms in [10, 30, 100]: |
| 403 | tlat = tlatv_ms * 1000 |
| 404 | pos = bisect.bisect_left(latv, tlat) |
| 405 | if 0 == pos: |
| 406 | iops3 = 0 |
| 407 | elif pos == len(latv): |
| 408 | iops3 = latv[-1] |
| 409 | else: |
| 410 | lat1 = latv[pos - 1] |
| 411 | lat2 = latv[pos] |
| 412 | |
koder aka kdanilov | f86d7af | 2015-05-06 04:01:54 +0300 | [diff] [blame] | 413 | iops1, _, th1 = rws4k_iops_lat_th[pos - 1] |
| 414 | iops2, _, th2 = rws4k_iops_lat_th[pos] |
koder aka kdanilov | 4a510ee | 2015-04-21 18:50:42 +0300 | [diff] [blame] | 415 | |
| 416 | th_lat_coef = (th2 - th1) / (lat2 - lat1) |
| 417 | th3 = th_lat_coef * (tlat - lat1) + th1 |
| 418 | |
| 419 | th_iops_coef = (iops2 - iops1) / (th2 - th1) |
| 420 | iops3 = th_iops_coef * (th3 - th1) + iops1 |
| 421 | setattr(di, 'rws4k_{}ms'.format(tlatv_ms), int(iops3)) |
| 422 | |
| 423 | hdi = DiskInfo() |
koder aka kdanilov | 7e0f7cf | 2015-05-01 17:24:35 +0300 | [diff] [blame] | 424 | |
| 425 | def pp(x): |
koder aka kdanilov | f86d7af | 2015-05-06 04:01:54 +0300 | [diff] [blame] | 426 | med, conf = x.rounded_average_conf() |
| 427 | conf_perc = int(float(conf) / med * 100) |
| 428 | return (med, conf_perc) |
koder aka kdanilov | 7e0f7cf | 2015-05-01 17:24:35 +0300 | [diff] [blame] | 429 | |
| 430 | hdi.direct_iops_r_max = pp(di.direct_iops_r_max) |
| 431 | hdi.direct_iops_w_max = pp(di.direct_iops_w_max) |
| 432 | hdi.bw_write_max = pp(di.bw_write_max) |
| 433 | hdi.bw_read_max = pp(di.bw_read_max) |
| 434 | |
koder aka kdanilov | c368eb6 | 2015-04-28 18:22:01 +0300 | [diff] [blame] | 435 | hdi.rws4k_10ms = di.rws4k_10ms if 0 != di.rws4k_10ms else None |
| 436 | hdi.rws4k_30ms = di.rws4k_30ms if 0 != di.rws4k_30ms else None |
| 437 | 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] | 438 | return hdi |
| 439 | |
| 440 | |
koder aka kdanilov | 57ce4db | 2015-04-25 21:25:51 +0300 | [diff] [blame] | 441 | @report('HDD', 'hdd_test_rrd4k,hdd_test_rws4k') |
koder aka kdanilov | d5ed4da | 2015-05-07 23:33:23 +0300 | [diff] [blame] | 442 | def make_hdd_report(processed_results, path, charts_path, lab_info): |
| 443 | img_ext = make_hdd_plots(processed_results, charts_path) |
koder aka kdanilov | a4a570f | 2015-04-23 22:11:40 +0300 | [diff] [blame] | 444 | di = get_disk_info(processed_results) |
koder aka kdanilov | d5ed4da | 2015-05-07 23:33:23 +0300 | [diff] [blame] | 445 | render_hdd_html(path, di, lab_info, img_ext) |
koder aka kdanilov | 63ad206 | 2015-04-27 13:11:40 +0300 | [diff] [blame] | 446 | |
| 447 | |
| 448 | @report('Ceph', 'ceph_test') |
koder aka kdanilov | d5ed4da | 2015-05-07 23:33:23 +0300 | [diff] [blame] | 449 | def make_ceph_report(processed_results, path, charts_path, lab_info): |
| 450 | img_ext = make_ceph_plots(processed_results, charts_path) |
koder aka kdanilov | 63ad206 | 2015-04-27 13:11:40 +0300 | [diff] [blame] | 451 | di = get_disk_info(processed_results) |
koder aka kdanilov | d5ed4da | 2015-05-07 23:33:23 +0300 | [diff] [blame] | 452 | render_ceph_html(path, di, lab_info, img_ext) |
koder aka kdanilov | a4a570f | 2015-04-23 22:11:40 +0300 | [diff] [blame] | 453 | |
| 454 | |
koder aka kdanilov | d5ed4da | 2015-05-07 23:33:23 +0300 | [diff] [blame] | 455 | def make_io_report(dinfo, results, path, charts_path, lab_info=None): |
koder aka kdanilov | f86d7af | 2015-05-06 04:01:54 +0300 | [diff] [blame] | 456 | lab_info = { |
| 457 | "total_disk": "None", |
| 458 | "total_memory": "None", |
| 459 | "nodes_count": "None", |
| 460 | "processor_count": "None" |
| 461 | } |
koder aka kdanilov | cff7b2e | 2015-04-18 20:48:15 +0300 | [diff] [blame] | 462 | |
koder aka kdanilov | a047e1b | 2015-04-21 23:16:59 +0300 | [diff] [blame] | 463 | try: |
koder aka kdanilov | f86d7af | 2015-05-06 04:01:54 +0300 | [diff] [blame] | 464 | res_fields = sorted(dinfo.keys()) |
koder aka kdanilov | 57ce4db | 2015-04-25 21:25:51 +0300 | [diff] [blame] | 465 | for fields, name, func in report_funcs: |
koder aka kdanilov | afd9874 | 2015-04-24 01:27:22 +0300 | [diff] [blame] | 466 | for field in fields: |
koder aka kdanilov | 57ce4db | 2015-04-25 21:25:51 +0300 | [diff] [blame] | 467 | pos = bisect.bisect_left(res_fields, field) |
| 468 | |
| 469 | if pos == len(res_fields): |
koder aka kdanilov | 63ad206 | 2015-04-27 13:11:40 +0300 | [diff] [blame] | 470 | break |
koder aka kdanilov | 57ce4db | 2015-04-25 21:25:51 +0300 | [diff] [blame] | 471 | |
koder aka kdanilov | be8f89f | 2015-04-28 14:51:51 +0300 | [diff] [blame] | 472 | if not res_fields[pos].startswith(field): |
koder aka kdanilov | afd9874 | 2015-04-24 01:27:22 +0300 | [diff] [blame] | 473 | break |
| 474 | else: |
koder aka kdanilov | 57ce4db | 2015-04-25 21:25:51 +0300 | [diff] [blame] | 475 | hpath = path.format(name) |
koder aka kdanilov | 63ad206 | 2015-04-27 13:11:40 +0300 | [diff] [blame] | 476 | logger.debug("Generatins report " + name + " into " + hpath) |
koder aka kdanilov | d5ed4da | 2015-05-07 23:33:23 +0300 | [diff] [blame] | 477 | func(dinfo, hpath, charts_path, lab_info) |
koder aka kdanilov | afd9874 | 2015-04-24 01:27:22 +0300 | [diff] [blame] | 478 | break |
koder aka kdanilov | a4a570f | 2015-04-23 22:11:40 +0300 | [diff] [blame] | 479 | else: |
| 480 | logger.warning("No report generator found for this load") |
koder aka kdanilov | afd9874 | 2015-04-24 01:27:22 +0300 | [diff] [blame] | 481 | |
koder aka kdanilov | a047e1b | 2015-04-21 23:16:59 +0300 | [diff] [blame] | 482 | except Exception as exc: |
koder aka kdanilov | 57ce4db | 2015-04-25 21:25:51 +0300 | [diff] [blame] | 483 | import traceback |
| 484 | traceback.print_exc() |
koder aka kdanilov | ec1b973 | 2015-04-23 20:43:29 +0300 | [diff] [blame] | 485 | logger.error("Failed to generate html report:" + str(exc)) |