blob: cb871b3fd8ed1b4a1b821d3067f884318c14b8af [file] [log] [blame]
koder aka kdanilovcff7b2e2015-04-18 20:48:15 +03001import os
koder aka kdanilov88407ff2015-05-26 15:35:57 +03002import csv
koder aka kdanilov4a510ee2015-04-21 18:50:42 +03003import bisect
koder aka kdanilova047e1b2015-04-21 23:16:59 +03004import logging
koder aka kdanilov88407ff2015-05-26 15:35:57 +03005import itertools
koder aka kdanilov416b87a2015-05-12 00:26:04 +03006import collections
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +03007from cStringIO import StringIO
koder aka kdanilovcff7b2e2015-04-18 20:48:15 +03008
koder aka kdanilovbe8f89f2015-04-28 14:51:51 +03009try:
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +030010 import numpy
11 import scipy
koder aka kdanilovbe8f89f2015-04-28 14:51:51 +030012 import matplotlib.pyplot as plt
13except ImportError:
14 plt = None
15
koder aka kdanilov4a510ee2015-04-21 18:50:42 +030016import wally
koder aka kdanilovf86d7af2015-05-06 04:01:54 +030017from wally.utils import ssize2b
koder aka kdanilovbb6d6cd2015-06-20 02:55:07 +030018from wally.statistic import round_3_digit
koder aka kdanilov88407ff2015-05-26 15:35:57 +030019from wally.suits.io.fio_task_parser import (get_test_sync_mode,
20 get_test_summary,
21 parse_all_in_1,
22 abbv_name_to_full)
koder aka kdanilovcff7b2e2015-04-18 20:48:15 +030023
koder aka kdanilov4a510ee2015-04-21 18:50:42 +030024
koder aka kdanilova047e1b2015-04-21 23:16:59 +030025logger = logging.getLogger("wally.report")
26
27
koder aka kdanilov209e85d2015-04-27 23:11:05 +030028class DiskInfo(object):
29 def __init__(self):
30 self.direct_iops_r_max = 0
31 self.direct_iops_w_max = 0
koder aka kdanilov88407ff2015-05-26 15:35:57 +030032
33 # 64 used instead of 4k to faster feed caches
34 self.direct_iops_w64_max = 0
35
koder aka kdanilov209e85d2015-04-27 23:11:05 +030036 self.rws4k_10ms = 0
37 self.rws4k_30ms = 0
38 self.rws4k_100ms = 0
39 self.bw_write_max = 0
40 self.bw_read_max = 0
41
42
koder aka kdanilovbe8f89f2015-04-28 14:51:51 +030043report_funcs = []
44
45
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +030046class Attrmapper(object):
47 def __init__(self, dct):
48 self.__dct = dct
49
50 def __getattr__(self, name):
51 try:
52 return self.__dct[name]
53 except KeyError:
54 raise AttributeError(name)
55
56
koder aka kdanilovf86d7af2015-05-06 04:01:54 +030057class PerfInfo(object):
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +030058 def __init__(self, name, summary, intervals, params, testnodes_count):
koder aka kdanilovf86d7af2015-05-06 04:01:54 +030059 self.name = name
60 self.bw = None
61 self.iops = None
62 self.lat = None
koder aka kdanilov88407ff2015-05-26 15:35:57 +030063 self.lat_50 = None
64 self.lat_95 = None
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +030065
66 self.raw_bw = []
67 self.raw_iops = []
68 self.raw_lat = []
69
koder aka kdanilov416b87a2015-05-12 00:26:04 +030070 self.params = params
71 self.intervals = intervals
72 self.testnodes_count = testnodes_count
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +030073 self.summary = summary
74 self.p = Attrmapper(self.params.vals)
koder aka kdanilovf86d7af2015-05-06 04:01:54 +030075
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +030076 self.sync_mode = get_test_sync_mode(self.params)
77 self.concurence = self.params.vals.get('numjobs', 1)
koder aka kdanilovf86d7af2015-05-06 04:01:54 +030078
79
koder aka kdanilovfd2cfa52015-05-20 03:17:42 +030080# disk_info = None
81# base = None
82# linearity = None
83
84
koder aka kdanilov416b87a2015-05-12 00:26:04 +030085def group_by_name(test_data):
86 name_map = collections.defaultdict(lambda: [])
87
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +030088 for data in test_data:
koder aka kdanilovbb6d6cd2015-06-20 02:55:07 +030089 name_map[(data.name, data.summary())].append(data)
koder aka kdanilov416b87a2015-05-12 00:26:04 +030090
91 return name_map
92
93
koder aka kdanilovbe8f89f2015-04-28 14:51:51 +030094def report(name, required_fields):
95 def closure(func):
96 report_funcs.append((required_fields.split(","), name, func))
97 return func
98 return closure
99
100
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300101def get_test_lcheck_params(pinfo):
102 res = [{
103 's': 'sync',
104 'd': 'direct',
105 'a': 'async',
106 'x': 'sync direct'
107 }[pinfo.sync_mode]]
koder aka kdanilovbe8f89f2015-04-28 14:51:51 +0300108
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300109 res.append(pinfo.p.rw)
koder aka kdanilovbe8f89f2015-04-28 14:51:51 +0300110
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300111 return " ".join(res)
koder aka kdanilov63e9c5a2015-04-28 23:06:07 +0300112
113
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300114def get_emb_data_svg(plt):
115 sio = StringIO()
116 plt.savefig(sio, format='svg')
117 img_start = "<!-- Created with matplotlib (http://matplotlib.org/) -->"
118 return sio.getvalue().split(img_start, 1)[1]
koder aka kdanilovbe8f89f2015-04-28 14:51:51 +0300119
120
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300121def get_template(templ_name):
koder aka kdanilov4a510ee2015-04-21 18:50:42 +0300122 very_root_dir = os.path.dirname(os.path.dirname(wally.__file__))
123 templ_dir = os.path.join(very_root_dir, 'report_templates')
koder aka kdanilovf86d7af2015-05-06 04:01:54 +0300124 templ_file = os.path.join(templ_dir, templ_name)
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300125 return open(templ_file, 'r').read()
koder aka kdanilov209e85d2015-04-27 23:11:05 +0300126
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300127
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300128def group_by(data, func):
129 if len(data) < 2:
130 yield data
131 return
132
133 ndata = [(func(dt), dt) for dt in data]
134 ndata.sort(key=func)
135 pkey, dt = ndata[0]
136 curr_list = [dt]
137
138 for key, val in ndata[1:]:
139 if pkey != key:
140 yield curr_list
141 curr_list = [val]
142 else:
143 curr_list.append(val)
144 pkey = key
145
146 yield curr_list
147
148
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300149@report('linearity', 'linearity_test')
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300150def linearity_report(processed_results, lab_info, comment):
151 labels_and_data_mp = collections.defaultdict(lambda: [])
152 vls = {}
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300153
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300154 # plot io_time = func(bsize)
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300155 for res in processed_results.values():
156 if res.name.startswith('linearity_test'):
157 iotimes = [1000. / val for val in res.iops.raw]
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300158
159 op_summ = get_test_summary(res.params)[:3]
160
161 labels_and_data_mp[op_summ].append(
162 [res.p.blocksize, res.iops.raw, iotimes])
163
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300164 cvls = res.params.vals.copy()
165 del cvls['blocksize']
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300166 del cvls['rw']
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300167
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300168 cvls.pop('sync', None)
169 cvls.pop('direct', None)
170 cvls.pop('buffered', None)
171
172 if op_summ not in vls:
173 vls[op_summ] = cvls
174 else:
175 assert cvls == vls[op_summ]
176
177 all_labels = None
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300178 _, ax1 = plt.subplots()
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300179 for name, labels_and_data in labels_and_data_mp.items():
180 labels_and_data.sort(key=lambda x: ssize2b(x[0]))
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300181
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300182 labels, _, iotimes = zip(*labels_and_data)
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300183
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300184 if all_labels is None:
185 all_labels = labels
186 else:
187 assert all_labels == labels
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300188
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300189 plt.boxplot(iotimes)
190 if len(labels_and_data) > 2 and \
191 ssize2b(labels_and_data[-2][0]) >= 4096:
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300192
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300193 xt = range(1, len(labels) + 1)
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300194
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300195 def io_time(sz, bw, initial_lat):
196 return sz / bw + initial_lat
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300197
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300198 x = numpy.array(map(ssize2b, labels))
199 y = numpy.array([sum(dt) / len(dt) for dt in iotimes])
200 popt, _ = scipy.optimize.curve_fit(io_time, x, y, p0=(100., 1.))
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300201
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300202 y1 = io_time(x, *popt)
203 plt.plot(xt, y1, linestyle='--',
204 label=name + ' LS linear approx')
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300205
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300206 for idx, (sz, _, _) in enumerate(labels_and_data):
207 if ssize2b(sz) >= 4096:
208 break
209
210 bw = (x[-1] - x[idx]) / (y[-1] - y[idx])
211 lat = y[-1] - x[-1] / bw
212 y2 = io_time(x, bw, lat)
213 plt.plot(xt, y2, linestyle='--',
214 label=abbv_name_to_full(name) +
215 ' (4k & max) linear approx')
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300216
217 plt.setp(ax1, xticklabels=labels)
218
219 plt.xlabel("Block size")
220 plt.ylabel("IO time, ms")
221
koder aka kdanilovfd2cfa52015-05-20 03:17:42 +0300222 plt.subplots_adjust(top=0.85)
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300223 plt.legend(bbox_to_anchor=(0.5, 1.15),
224 loc='upper center',
225 prop={'size': 10}, ncol=2)
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300226 plt.grid()
227 iotime_plot = get_emb_data_svg(plt)
koder aka kdanilovfd2cfa52015-05-20 03:17:42 +0300228 plt.clf()
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300229
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300230 # plot IOPS = func(bsize)
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300231 _, ax1 = plt.subplots()
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300232
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300233 for name, labels_and_data in labels_and_data_mp.items():
234 labels_and_data.sort(key=lambda x: ssize2b(x[0]))
235 _, data, _ = zip(*labels_and_data)
236 plt.boxplot(data)
237 avg = [float(sum(arr)) / len(arr) for arr in data]
238 xt = range(1, len(data) + 1)
239 plt.plot(xt, avg, linestyle='--',
240 label=abbv_name_to_full(name) + " avg")
241
242 plt.setp(ax1, xticklabels=labels)
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300243 plt.xlabel("Block size")
244 plt.ylabel("IOPS")
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300245 plt.legend(bbox_to_anchor=(0.5, 1.15),
246 loc='upper center',
247 prop={'size': 10}, ncol=2)
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300248 plt.grid()
koder aka kdanilovfd2cfa52015-05-20 03:17:42 +0300249 plt.subplots_adjust(top=0.85)
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300250
251 iops_plot = get_emb_data_svg(plt)
252
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300253 res = set(get_test_lcheck_params(res) for res in processed_results.values())
254 ncount = list(set(res.testnodes_count for res in processed_results.values()))
255 conc = list(set(res.concurence for res in processed_results.values()))
256
257 assert len(conc) == 1
258 assert len(ncount) == 1
259
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300260 descr = {
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300261 'vm_count': ncount[0],
262 'concurence': conc[0],
263 'oper_descr': ", ".join(res).capitalize()
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300264 }
265
266 params_map = {'iotime_vs_size': iotime_plot,
267 'iops_vs_size': iops_plot,
268 'descr': descr}
269
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300270 return get_template('report_linearity.html').format(**params_map)
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300271
272
273@report('lat_vs_iops', 'lat_vs_iops')
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300274def lat_vs_iops(processed_results, lab_info, comment):
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300275 lat_iops = collections.defaultdict(lambda: [])
koder aka kdanilovfd2cfa52015-05-20 03:17:42 +0300276 requsted_vs_real = collections.defaultdict(lambda: {})
277
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300278 for res in processed_results.values():
279 if res.name.startswith('lat_vs_iops'):
koder aka kdanilovf236b9c2015-06-24 18:17:22 +0300280 lat_iops[res.concurence].append((res.lat,
281 0,
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300282 res.iops.average,
283 res.iops.deviation))
koder aka kdanilovf236b9c2015-06-24 18:17:22 +0300284 # lat_iops[res.concurence].append((res.lat.average / 1000.0,
285 # res.lat.deviation / 1000.0,
286 # res.iops.average,
287 # res.iops.deviation))
koder aka kdanilovfd2cfa52015-05-20 03:17:42 +0300288 requested_iops = res.p.rate_iops * res.concurence
289 requsted_vs_real[res.concurence][requested_iops] = \
290 (res.iops.average, res.iops.deviation)
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300291
koder aka kdanilovfd2cfa52015-05-20 03:17:42 +0300292 colors = ['red', 'green', 'blue', 'orange', 'magenta', "teal"]
293 colors_it = iter(colors)
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300294 for conc, lat_iops in sorted(lat_iops.items()):
295 lat, dev, iops, iops_dev = zip(*lat_iops)
296 plt.errorbar(iops, lat, xerr=iops_dev, yerr=dev, fmt='ro',
297 label=str(conc) + " threads",
koder aka kdanilovfd2cfa52015-05-20 03:17:42 +0300298 color=next(colors_it))
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300299
300 plt.xlabel("IOPS")
301 plt.ylabel("Latency, ms")
302 plt.grid()
303 plt.legend(loc=0)
koder aka kdanilovfd2cfa52015-05-20 03:17:42 +0300304 plt_iops_vs_lat = get_emb_data_svg(plt)
305 plt.clf()
306
307 colors_it = iter(colors)
308 for conc, req_vs_real in sorted(requsted_vs_real.items()):
309 req, real = zip(*sorted(req_vs_real.items()))
310 iops, dev = zip(*real)
311 plt.errorbar(req, iops, yerr=dev, fmt='ro',
312 label=str(conc) + " threads",
313 color=next(colors_it))
314 plt.xlabel("Requested IOPS")
315 plt.ylabel("Get IOPS")
316 plt.grid()
317 plt.legend(loc=0)
318 plt_iops_vs_requested = get_emb_data_svg(plt)
319
320 res1 = processed_results.values()[0]
321 params_map = {'iops_vs_lat': plt_iops_vs_lat,
322 'iops_vs_requested': plt_iops_vs_requested,
323 'oper_descr': get_test_lcheck_params(res1).capitalize()}
324
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300325 return get_template('report_iops_vs_lat.html').format(**params_map)
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300326
327
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300328def render_all_html(comment, info, lab_description, images, templ_name):
koder aka kdanilovf86d7af2015-05-06 04:01:54 +0300329 data = info.__dict__.copy()
330 for name, val in data.items():
koder aka kdanilov209e85d2015-04-27 23:11:05 +0300331 if not name.startswith('__'):
koder aka kdanilovc368eb62015-04-28 18:22:01 +0300332 if val is None:
koder aka kdanilovf86d7af2015-05-06 04:01:54 +0300333 data[name] = '-'
334 elif isinstance(val, (int, float, long)):
335 data[name] = round_3_digit(val)
koder aka kdanilov209e85d2015-04-27 23:11:05 +0300336
koder aka kdanilovf86d7af2015-05-06 04:01:54 +0300337 data['bw_read_max'] = (data['bw_read_max'][0] // 1024,
338 data['bw_read_max'][1])
339 data['bw_write_max'] = (data['bw_write_max'][0] // 1024,
340 data['bw_write_max'][1])
koder aka kdanilov7e0f7cf2015-05-01 17:24:35 +0300341
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300342 images.update(data)
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300343 return get_template(templ_name).format(lab_info=lab_description,
344 comment=comment,
345 **images)
koder aka kdanilovcff7b2e2015-04-18 20:48:15 +0300346
347
koder aka kdanilovf86d7af2015-05-06 04:01:54 +0300348def io_chart(title, concurence,
349 latv, latv_min, latv_max,
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300350 iops_or_bw, iops_or_bw_err,
koder aka kdanilovf236b9c2015-06-24 18:17:22 +0300351 legend,
352 log_iops=False,
353 log_lat=False,
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300354 boxplots=False,
355 latv_50=None, latv_95=None):
koder aka kdanilovd5ed4da2015-05-07 23:33:23 +0300356 points = " MiBps" if legend == 'BW' else ""
357 lc = len(concurence)
358 width = 0.35
359 xt = range(1, lc + 1)
360
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300361 op_per_vm = [v / (vm * th) for v, (vm, th) in zip(iops_or_bw, concurence)]
koder aka kdanilovd5ed4da2015-05-07 23:33:23 +0300362 fig, p1 = plt.subplots()
363 xpos = [i - width / 2 for i in xt]
364
koder aka kdanilov416b87a2015-05-12 00:26:04 +0300365 p1.bar(xpos, iops_or_bw,
366 width=width,
367 yerr=iops_or_bw_err,
368 ecolor='m',
koder aka kdanilovd5ed4da2015-05-07 23:33:23 +0300369 color='y',
370 label=legend)
371
koder aka kdanilovd5ed4da2015-05-07 23:33:23 +0300372 p1.grid(True)
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300373 p1.plot(xt, op_per_vm, '--', label=legend + "/thread", color='black')
koder aka kdanilov416b87a2015-05-12 00:26:04 +0300374 handles1, labels1 = p1.get_legend_handles_labels()
koder aka kdanilovd5ed4da2015-05-07 23:33:23 +0300375
376 p2 = p1.twinx()
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300377
378 if latv_50 is None:
379 p2.plot(xt, latv_max, label="lat max")
380 p2.plot(xt, latv, label="lat avg")
381 p2.plot(xt, latv_min, label="lat min")
382 else:
383 p2.plot(xt, latv_50, label="lat med")
384 p2.plot(xt, latv_95, label="lat 95%")
koder aka kdanilovd5ed4da2015-05-07 23:33:23 +0300385
386 plt.xlim(0.5, lc + 0.5)
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300387 plt.xticks(xt, ["{0} * {1}".format(vm, th) for (vm, th) in concurence])
388 p1.set_xlabel("VM Count * Thread per VM")
koder aka kdanilovd5ed4da2015-05-07 23:33:23 +0300389 p1.set_ylabel(legend + points)
390 p2.set_ylabel("Latency ms")
391 plt.title(title)
koder aka kdanilov416b87a2015-05-12 00:26:04 +0300392 handles2, labels2 = p2.get_legend_handles_labels()
393
394 plt.legend(handles1 + handles2, labels1 + labels2,
395 loc='center left', bbox_to_anchor=(1.1, 0.81))
koder aka kdanilov416b87a2015-05-12 00:26:04 +0300396
koder aka kdanilovf236b9c2015-06-24 18:17:22 +0300397 if log_iops:
koder aka kdanilov416b87a2015-05-12 00:26:04 +0300398 p1.set_yscale('log')
koder aka kdanilovf236b9c2015-06-24 18:17:22 +0300399
400 if log_lat:
koder aka kdanilov416b87a2015-05-12 00:26:04 +0300401 p2.set_yscale('log')
koder aka kdanilovf236b9c2015-06-24 18:17:22 +0300402
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300403 plt.subplots_adjust(right=0.68)
404
405 return get_emb_data_svg(plt)
koder aka kdanilovd5ed4da2015-05-07 23:33:23 +0300406
407
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300408def make_plots(processed_results, plots):
koder aka kdanilovbb6d6cd2015-06-20 02:55:07 +0300409 """
410 processed_results: [PerfInfo]
411 plots = [(test_name_prefix:str, fname:str, description:str)]
412 """
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300413 files = {}
koder aka kdanilov63ad2062015-04-27 13:11:40 +0300414 for name_pref, fname, desc in plots:
koder aka kdanilov4a510ee2015-04-21 18:50:42 +0300415 chart_data = []
koder aka kdanilov63ad2062015-04-27 13:11:40 +0300416
koder aka kdanilovbb6d6cd2015-06-20 02:55:07 +0300417 for res in processed_results:
418 summ = res.name + "_" + res.summary
419 if summ.startswith(name_pref):
koder aka kdanilov4a510ee2015-04-21 18:50:42 +0300420 chart_data.append(res)
421
koder aka kdanilov63ad2062015-04-27 13:11:40 +0300422 if len(chart_data) == 0:
423 raise ValueError("Can't found any date for " + name_pref)
424
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300425 use_bw = ssize2b(chart_data[0].p.blocksize) > 16 * 1024
koder aka kdanilov63ad2062015-04-27 13:11:40 +0300426
koder aka kdanilovbb6d6cd2015-06-20 02:55:07 +0300427 chart_data.sort(key=lambda x: x.params['vals']['numjobs'])
koder aka kdanilov4a510ee2015-04-21 18:50:42 +0300428
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300429 lat = None
430 lat_min = None
431 lat_max = None
koder aka kdanilovf236b9c2015-06-24 18:17:22 +0300432
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300433 lat_50 = [x.lat_50 for x in chart_data]
434 lat_95 = [x.lat_95 for x in chart_data]
koder aka kdanilovf86d7af2015-05-06 04:01:54 +0300435
koder aka kdanilovf236b9c2015-06-24 18:17:22 +0300436 lat_diff_max = max(x.lat_95 / x.lat_50 for x in chart_data)
437 lat_log_scale = (lat_diff_max > 10)
438
koder aka kdanilov416b87a2015-05-12 00:26:04 +0300439 testnodes_count = x.testnodes_count
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300440 concurence = [(testnodes_count, x.concurence)
koder aka kdanilov416b87a2015-05-12 00:26:04 +0300441 for x in chart_data]
koder aka kdanilov4a510ee2015-04-21 18:50:42 +0300442
koder aka kdanilov63ad2062015-04-27 13:11:40 +0300443 if use_bw:
koder aka kdanilovf86d7af2015-05-06 04:01:54 +0300444 data = [x.bw.average / 1000 for x in chart_data]
445 data_dev = [x.bw.confidence / 1000 for x in chart_data]
koder aka kdanilov63ad2062015-04-27 13:11:40 +0300446 name = "BW"
447 else:
koder aka kdanilovf86d7af2015-05-06 04:01:54 +0300448 data = [x.iops.average for x in chart_data]
449 data_dev = [x.iops.confidence for x in chart_data]
koder aka kdanilov63ad2062015-04-27 13:11:40 +0300450 name = "IOPS"
451
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300452 fc = io_chart(title=desc,
453 concurence=concurence,
koder aka kdanilovf236b9c2015-06-24 18:17:22 +0300454
koder aka kdanilovbb6d6cd2015-06-20 02:55:07 +0300455 latv=lat,
456 latv_min=lat_min,
457 latv_max=lat_max,
458
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300459 iops_or_bw=data,
460 iops_or_bw_err=data_dev,
koder aka kdanilovbb6d6cd2015-06-20 02:55:07 +0300461
462 legend=name,
koder aka kdanilovf236b9c2015-06-24 18:17:22 +0300463 log_lat=lat_log_scale,
koder aka kdanilovbb6d6cd2015-06-20 02:55:07 +0300464
465 latv_50=lat_50,
466 latv_95=lat_95)
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300467 files[fname] = fc
468
469 return files
koder aka kdanilov4a510ee2015-04-21 18:50:42 +0300470
471
koder aka kdanilov7e0f7cf2015-05-01 17:24:35 +0300472def find_max_where(processed_results, sync_mode, blocksize, rw, iops=True):
koder aka kdanilovf86d7af2015-05-06 04:01:54 +0300473 result = None
koder aka kdanilov7e0f7cf2015-05-01 17:24:35 +0300474 attr = 'iops' if iops else 'bw'
koder aka kdanilovbb6d6cd2015-06-20 02:55:07 +0300475 for measurement in processed_results:
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300476 ok = measurement.sync_mode == sync_mode
477 ok = ok and (measurement.p.blocksize == blocksize)
478 ok = ok and (measurement.p.rw == rw)
koder aka kdanilov7e0f7cf2015-05-01 17:24:35 +0300479
480 if ok:
koder aka kdanilovf86d7af2015-05-06 04:01:54 +0300481 field = getattr(measurement, attr)
482
483 if result is None:
484 result = field
485 elif field.average > result.average:
486 result = field
487
koder aka kdanilov7e0f7cf2015-05-01 17:24:35 +0300488 return result
489
490
koder aka kdanilov4a510ee2015-04-21 18:50:42 +0300491def get_disk_info(processed_results):
492 di = DiskInfo()
koder aka kdanilov7e0f7cf2015-05-01 17:24:35 +0300493 di.direct_iops_w_max = find_max_where(processed_results,
494 'd', '4k', 'randwrite')
495 di.direct_iops_r_max = find_max_where(processed_results,
496 'd', '4k', 'randread')
koder aka kdanilovf86d7af2015-05-06 04:01:54 +0300497
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300498 di.direct_iops_w64_max = find_max_where(processed_results,
499 'd', '64k', 'randwrite')
500
501 for sz in ('16m', '64m'):
502 di.bw_write_max = find_max_where(processed_results,
503 'd', sz, 'randwrite', False)
504 if di.bw_write_max is not None:
505 break
506
koder aka kdanilovf86d7af2015-05-06 04:01:54 +0300507 if di.bw_write_max is None:
508 di.bw_write_max = find_max_where(processed_results,
509 'd', '1m', 'write', False)
510
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300511 for sz in ('16m', '64m'):
512 di.bw_read_max = find_max_where(processed_results,
513 'd', sz, 'randread', False)
514 if di.bw_read_max is not None:
515 break
516
koder aka kdanilovf86d7af2015-05-06 04:01:54 +0300517 if di.bw_read_max is None:
518 di.bw_read_max = find_max_where(processed_results,
519 'd', '1m', 'read', False)
koder aka kdanilov7e0f7cf2015-05-01 17:24:35 +0300520
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300521 rws4k_iops_lat_th = []
koder aka kdanilovbb6d6cd2015-06-20 02:55:07 +0300522 for res in processed_results:
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300523 if res.sync_mode in 'xs' and res.p.blocksize == '4k':
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300524 if res.p.rw != 'randwrite':
koder aka kdanilov4a510ee2015-04-21 18:50:42 +0300525 continue
koder aka kdanilovf86d7af2015-05-06 04:01:54 +0300526 rws4k_iops_lat_th.append((res.iops.average,
koder aka kdanilovf236b9c2015-06-24 18:17:22 +0300527 res.lat,
528 # res.lat.average,
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300529 res.concurence))
koder aka kdanilov4a510ee2015-04-21 18:50:42 +0300530
koder aka kdanilov4a510ee2015-04-21 18:50:42 +0300531 rws4k_iops_lat_th.sort(key=lambda (_1, _2, conc): conc)
532
533 latv = [lat for _, lat, _ in rws4k_iops_lat_th]
534
535 for tlatv_ms in [10, 30, 100]:
536 tlat = tlatv_ms * 1000
537 pos = bisect.bisect_left(latv, tlat)
538 if 0 == pos:
koder aka kdanilovbb5fe072015-05-21 02:50:23 +0300539 setattr(di, 'rws4k_{}ms'.format(tlatv_ms), 0)
koder aka kdanilov4a510ee2015-04-21 18:50:42 +0300540 elif pos == len(latv):
koder aka kdanilovbb5fe072015-05-21 02:50:23 +0300541 iops3, _, _ = rws4k_iops_lat_th[-1]
542 setattr(di, 'rws4k_{}ms'.format(tlatv_ms), ">=" + str(iops3))
koder aka kdanilov4a510ee2015-04-21 18:50:42 +0300543 else:
544 lat1 = latv[pos - 1]
545 lat2 = latv[pos]
546
koder aka kdanilovf86d7af2015-05-06 04:01:54 +0300547 iops1, _, th1 = rws4k_iops_lat_th[pos - 1]
548 iops2, _, th2 = rws4k_iops_lat_th[pos]
koder aka kdanilov4a510ee2015-04-21 18:50:42 +0300549
550 th_lat_coef = (th2 - th1) / (lat2 - lat1)
551 th3 = th_lat_coef * (tlat - lat1) + th1
552
553 th_iops_coef = (iops2 - iops1) / (th2 - th1)
554 iops3 = th_iops_coef * (th3 - th1) + iops1
koder aka kdanilovbb5fe072015-05-21 02:50:23 +0300555 setattr(di, 'rws4k_{}ms'.format(tlatv_ms), int(iops3))
koder aka kdanilov4a510ee2015-04-21 18:50:42 +0300556
557 hdi = DiskInfo()
koder aka kdanilov7e0f7cf2015-05-01 17:24:35 +0300558
559 def pp(x):
koder aka kdanilovf86d7af2015-05-06 04:01:54 +0300560 med, conf = x.rounded_average_conf()
561 conf_perc = int(float(conf) / med * 100)
562 return (med, conf_perc)
koder aka kdanilov7e0f7cf2015-05-01 17:24:35 +0300563
564 hdi.direct_iops_r_max = pp(di.direct_iops_r_max)
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300565
566 if di.direct_iops_w_max is not None:
567 hdi.direct_iops_w_max = pp(di.direct_iops_w_max)
568 else:
569 hdi.direct_iops_w_max = None
570
571 if di.direct_iops_w64_max is not None:
572 hdi.direct_iops_w64_max = pp(di.direct_iops_w64_max)
573 else:
574 hdi.direct_iops_w64_max = None
575
koder aka kdanilov7e0f7cf2015-05-01 17:24:35 +0300576 hdi.bw_write_max = pp(di.bw_write_max)
577 hdi.bw_read_max = pp(di.bw_read_max)
578
koder aka kdanilovc368eb62015-04-28 18:22:01 +0300579 hdi.rws4k_10ms = di.rws4k_10ms if 0 != di.rws4k_10ms else None
580 hdi.rws4k_30ms = di.rws4k_30ms if 0 != di.rws4k_30ms else None
581 hdi.rws4k_100ms = di.rws4k_100ms if 0 != di.rws4k_100ms else None
koder aka kdanilov4a510ee2015-04-21 18:50:42 +0300582 return hdi
583
584
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300585@report('hdd', 'hdd')
586def make_hdd_report(processed_results, lab_info, comment):
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300587 plots = [
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300588 ('hdd_rrd4k', 'rand_read_4k', 'Random read 4k direct IOPS'),
589 ('hdd_rwx4k', 'rand_write_4k', 'Random write 4k sync IOPS')
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300590 ]
koder aka kdanilovbb6d6cd2015-06-20 02:55:07 +0300591 perf_infos = [res.disk_perf_info() for res in processed_results]
592 images = make_plots(perf_infos, plots)
593 di = get_disk_info(perf_infos)
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300594 return render_all_html(comment, di, lab_info, images, "report_hdd.html")
koder aka kdanilov63ad2062015-04-27 13:11:40 +0300595
596
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300597@report('cinder_iscsi', 'cinder_iscsi')
598def make_cinder_iscsi_report(processed_results, lab_info, comment):
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300599 plots = [
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300600 ('cinder_iscsi_rrd4k', 'rand_read_4k', 'Random read 4k direct IOPS'),
601 ('cinder_iscsi_rwx4k', 'rand_write_4k', 'Random write 4k sync IOPS')
602 ]
koder aka kdanilovbb6d6cd2015-06-20 02:55:07 +0300603 perf_infos = [res.disk_perf_info() for res in processed_results]
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300604 try:
koder aka kdanilovbb6d6cd2015-06-20 02:55:07 +0300605 images = make_plots(perf_infos, plots)
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300606 except ValueError:
607 plots = [
608 ('cinder_iscsi_rrd4k', 'rand_read_4k', 'Random read 4k direct IOPS'),
609 ('cinder_iscsi_rws4k', 'rand_write_4k', 'Random write 4k sync IOPS')
610 ]
koder aka kdanilovbb6d6cd2015-06-20 02:55:07 +0300611 images = make_plots(perf_infos, plots)
612 di = get_disk_info(perf_infos)
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300613 return render_all_html(comment, di, lab_info, images, "report_cinder_iscsi.html")
614
615
616@report('ceph', 'ceph')
617def make_ceph_report(processed_results, lab_info, comment):
618 plots = [
619 ('ceph_rrd4k', 'rand_read_4k', 'Random read 4k direct IOPS'),
620 ('ceph_rws4k', 'rand_write_4k', 'Random write 4k sync IOPS'),
621 ('ceph_rrd16m', 'rand_read_16m', 'Random read 16m direct MiBps'),
622 ('ceph_rwd16m', 'rand_write_16m',
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300623 'Random write 16m direct MiBps'),
624 ]
625
koder aka kdanilovbb6d6cd2015-06-20 02:55:07 +0300626 perf_infos = [res.disk_perf_info() for res in processed_results]
627 images = make_plots(perf_infos, plots)
628 di = get_disk_info(perf_infos)
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300629 return render_all_html(comment, di, lab_info, images, "report_ceph.html")
koder aka kdanilova4a570f2015-04-23 22:11:40 +0300630
631
koder aka kdanilov7248c7b2015-05-31 22:53:03 +0300632@report('mixed', 'mixed')
633def make_mixed_report(processed_results, lab_info, comment):
634 #
635 # IOPS(X% read) = 100 / ( X / IOPS_W + (100 - X) / IOPS_R )
636 #
koder aka kdanilovbb6d6cd2015-06-20 02:55:07 +0300637
638 perf_infos = [res.disk_perf_info() for res in processed_results]
koder aka kdanilov7248c7b2015-05-31 22:53:03 +0300639 mixed = collections.defaultdict(lambda: [])
koder aka kdanilovbb6d6cd2015-06-20 02:55:07 +0300640
641 is_ssd = False
642 for res in perf_infos:
koder aka kdanilov7248c7b2015-05-31 22:53:03 +0300643 if res.name.startswith('mixed'):
644 if res.name.startswith('mixed-ssd'):
645 is_ssd = True
646 mixed[res.concurence].append((res.p.rwmixread,
koder aka kdanilovf236b9c2015-06-24 18:17:22 +0300647 res.lat,
648 0,
649 # res.lat.average / 1000.0,
650 # res.lat.deviation / 1000.0,
koder aka kdanilov7248c7b2015-05-31 22:53:03 +0300651 res.iops.average,
652 res.iops.deviation))
653
654 if len(mixed) == 0:
655 raise ValueError("No mixed load found")
656
657 fig, p1 = plt.subplots()
658 p2 = p1.twinx()
659
660 colors = ['red', 'green', 'blue', 'orange', 'magenta', "teal"]
661 colors_it = iter(colors)
662 for conc, mix_lat_iops in sorted(mixed.items()):
663 mix_lat_iops = sorted(mix_lat_iops)
664 read_perc, lat, dev, iops, iops_dev = zip(*mix_lat_iops)
665 p1.errorbar(read_perc, iops, color=next(colors_it),
666 yerr=iops_dev, label=str(conc) + " th")
667
668 p2.errorbar(read_perc, lat, color=next(colors_it),
669 ls='--', yerr=dev, label=str(conc) + " th lat")
670
671 if is_ssd:
672 p1.set_yscale('log')
673 p2.set_yscale('log')
674
675 p1.set_xlim(-5, 105)
676
677 read_perc = set(read_perc)
678 read_perc.add(0)
679 read_perc.add(100)
680 read_perc = sorted(read_perc)
681
682 plt.xticks(read_perc, map(str, read_perc))
683
684 p1.grid(True)
685 p1.set_xlabel("% of reads")
686 p1.set_ylabel("Mixed IOPS")
687 p2.set_ylabel("Latency, ms")
688
689 handles1, labels1 = p1.get_legend_handles_labels()
690 handles2, labels2 = p2.get_legend_handles_labels()
691 plt.subplots_adjust(top=0.85)
692 plt.legend(handles1 + handles2, labels1 + labels2,
693 bbox_to_anchor=(0.5, 1.15),
694 loc='upper center',
695 prop={'size': 12}, ncol=3)
696 plt.show()
697
698
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300699def make_load_report(idx, results_dir, fname):
700 dpath = os.path.join(results_dir, "io_" + str(idx))
701 files = sorted(os.listdir(dpath))
702 gf = lambda x: "_".join(x.rsplit(".", 1)[0].split('_')[:3])
703
704 for key, group in itertools.groupby(files, gf):
705 fname = os.path.join(dpath, key + ".fio")
706
707 cfgs = list(parse_all_in_1(open(fname).read(), fname))
708
709 fname = os.path.join(dpath, key + "_lat.log")
710
711 curr = []
712 arrays = []
713
714 with open(fname) as fd:
715 for offset, lat, _, _ in csv.reader(fd):
716 offset = int(offset)
717 lat = int(lat)
718 if len(curr) > 0 and curr[-1][0] > offset:
719 arrays.append(curr)
720 curr = []
721 curr.append((offset, lat))
722 arrays.append(curr)
723 conc = int(cfgs[0].vals.get('numjobs', 1))
724
725 if conc != 5:
726 continue
727
728 assert len(arrays) == len(cfgs) * conc
729
730 garrays = [[(0, 0)] for _ in range(conc)]
731
732 for offset in range(len(cfgs)):
733 for acc, new_arr in zip(garrays, arrays[offset * conc:(offset + 1) * conc]):
734 last = acc[-1][0]
735 for off, lat in new_arr:
736 acc.append((off / 1000. + last, lat / 1000.))
737
738 for cfg, arr in zip(cfgs, garrays):
739 plt.plot(*zip(*arr[1:]))
740 plt.show()
741 exit(1)
742
743
744def make_io_report(dinfo, comment, path, lab_info=None):
koder aka kdanilovf86d7af2015-05-06 04:01:54 +0300745 lab_info = {
746 "total_disk": "None",
747 "total_memory": "None",
748 "nodes_count": "None",
749 "processor_count": "None"
750 }
koder aka kdanilovcff7b2e2015-04-18 20:48:15 +0300751
koder aka kdanilova047e1b2015-04-21 23:16:59 +0300752 try:
koder aka kdanilovbb6d6cd2015-06-20 02:55:07 +0300753 res_fields = sorted(v.name for v in dinfo)
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300754
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300755 found = False
koder aka kdanilov57ce4db2015-04-25 21:25:51 +0300756 for fields, name, func in report_funcs:
koder aka kdanilovafd98742015-04-24 01:27:22 +0300757 for field in fields:
koder aka kdanilov57ce4db2015-04-25 21:25:51 +0300758 pos = bisect.bisect_left(res_fields, field)
759
760 if pos == len(res_fields):
koder aka kdanilov63ad2062015-04-27 13:11:40 +0300761 break
koder aka kdanilov57ce4db2015-04-25 21:25:51 +0300762
koder aka kdanilovbe8f89f2015-04-28 14:51:51 +0300763 if not res_fields[pos].startswith(field):
koder aka kdanilovafd98742015-04-24 01:27:22 +0300764 break
765 else:
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300766 found = True
koder aka kdanilov57ce4db2015-04-25 21:25:51 +0300767 hpath = path.format(name)
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300768
769 try:
770 report = func(dinfo, lab_info, comment)
771 except:
772 logger.exception("Diring {0} report generation".format(name))
773 continue
774
koder aka kdanilov7248c7b2015-05-31 22:53:03 +0300775 if report is not None:
776 try:
777 with open(hpath, "w") as fd:
778 fd.write(report)
779 except:
780 logger.exception("Diring saving {0} report".format(name))
781 continue
782 logger.info("Report {0} saved into {1}".format(name, hpath))
783 else:
784 logger.warning("No report produced by {0!r}".format(name))
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300785
786 if not found:
koder aka kdanilova4a570f2015-04-23 22:11:40 +0300787 logger.warning("No report generator found for this load")
koder aka kdanilovafd98742015-04-24 01:27:22 +0300788
koder aka kdanilova047e1b2015-04-21 23:16:59 +0300789 except Exception as exc:
koder aka kdanilov57ce4db2015-04-25 21:25:51 +0300790 import traceback
791 traceback.print_exc()
koder aka kdanilovec1b9732015-04-23 20:43:29 +0300792 logger.error("Failed to generate html report:" + str(exc))