blob: e893c255f6f48daa77f1919bd79858aa5c624a87 [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
18from wally.statistic import round_3_digit, data_property
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:
89 name_map[(data.config.name, data.summary())].append(data)
koder aka kdanilov416b87a2015-05-12 00:26:04 +030090
91 return name_map
92
93
koder aka kdanilov88407ff2015-05-26 15:35:57 +030094def get_lat_perc_50_95(lat_mks):
95 curr_perc = 0
96 perc_50 = None
97 perc_95 = None
98 pkey = None
99 for key, val in sorted(lat_mks.items()):
100 if curr_perc + val >= 50 and perc_50 is None:
101 if pkey is None or val < 1.:
102 perc_50 = key
103 else:
104 perc_50 = (50. - curr_perc) / val * (key - pkey) + pkey
105
106 if curr_perc + val >= 95:
107 if pkey is None or val < 1.:
108 perc_95 = key
109 else:
110 perc_95 = (95. - curr_perc) / val * (key - pkey) + pkey
111 break
112
113 pkey = key
114 curr_perc += val
115
116 return perc_50 / 1000., perc_95 / 1000.
117
118
koder aka kdanilovf86d7af2015-05-06 04:01:54 +0300119def process_disk_info(test_data):
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300120
koder aka kdanilov416b87a2015-05-12 00:26:04 +0300121 name_map = group_by_name(test_data)
koder aka kdanilovf86d7af2015-05-06 04:01:54 +0300122 data = {}
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300123 for (name, summary), results in name_map.items():
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300124 lat_mks = collections.defaultdict(lambda: 0)
125 num_res = 0
126
127 for result in results:
128 num_res += len(result.raw_result['jobs'])
129 for job_info in result.raw_result['jobs']:
130 for k, v in job_info['latency_ms'].items():
koder aka kdanilov7248c7b2015-05-31 22:53:03 +0300131 if isinstance(k, basestring) and k.startswith('>='):
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300132 lat_mks[int(k[2:]) * 1000] += v
133 else:
koder aka kdanilov7248c7b2015-05-31 22:53:03 +0300134 lat_mks[int(k) * 1000] += v
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300135
136 for k, v in job_info['latency_us'].items():
koder aka kdanilov7248c7b2015-05-31 22:53:03 +0300137 lat_mks[int(k)] += v
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300138
139 for k, v in lat_mks.items():
140 lat_mks[k] = float(v) / num_res
141
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300142 testnodes_count_set = set(dt.vm_count for dt in results)
koder aka kdanilovf86d7af2015-05-06 04:01:54 +0300143
koder aka kdanilov416b87a2015-05-12 00:26:04 +0300144 assert len(testnodes_count_set) == 1
145 testnodes_count, = testnodes_count_set
146 assert len(results) % testnodes_count == 0
koder aka kdanilovf86d7af2015-05-06 04:01:54 +0300147
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300148 intervals = [result.run_interval for result in results]
149 p = results[0].config
150 pinfo = PerfInfo(p.name, result.summary(), intervals,
151 p, testnodes_count)
koder aka kdanilov416b87a2015-05-12 00:26:04 +0300152
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300153 pinfo.raw_bw = [result.results['bw'] for result in results]
154 pinfo.raw_iops = [result.results['iops'] for result in results]
155 pinfo.raw_lat = [result.results['lat'] for result in results]
koder aka kdanilov416b87a2015-05-12 00:26:04 +0300156
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300157 pinfo.bw = data_property(map(sum, zip(*pinfo.raw_bw)))
158 pinfo.iops = data_property(map(sum, zip(*pinfo.raw_iops)))
159 pinfo.lat = data_property(sum(pinfo.raw_lat, []))
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300160 pinfo.lat_50, pinfo.lat_95 = get_lat_perc_50_95(lat_mks)
koder aka kdanilov416b87a2015-05-12 00:26:04 +0300161
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300162 data[(p.name, summary)] = pinfo
koder aka kdanilovf86d7af2015-05-06 04:01:54 +0300163 return data
164
165
koder aka kdanilovbe8f89f2015-04-28 14:51:51 +0300166def report(name, required_fields):
167 def closure(func):
168 report_funcs.append((required_fields.split(","), name, func))
169 return func
170 return closure
171
172
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300173def get_test_lcheck_params(pinfo):
174 res = [{
175 's': 'sync',
176 'd': 'direct',
177 'a': 'async',
178 'x': 'sync direct'
179 }[pinfo.sync_mode]]
koder aka kdanilovbe8f89f2015-04-28 14:51:51 +0300180
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300181 res.append(pinfo.p.rw)
koder aka kdanilovbe8f89f2015-04-28 14:51:51 +0300182
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300183 return " ".join(res)
koder aka kdanilov63e9c5a2015-04-28 23:06:07 +0300184
185
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300186def get_emb_data_svg(plt):
187 sio = StringIO()
188 plt.savefig(sio, format='svg')
189 img_start = "<!-- Created with matplotlib (http://matplotlib.org/) -->"
190 return sio.getvalue().split(img_start, 1)[1]
koder aka kdanilovbe8f89f2015-04-28 14:51:51 +0300191
192
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300193def get_template(templ_name):
koder aka kdanilov4a510ee2015-04-21 18:50:42 +0300194 very_root_dir = os.path.dirname(os.path.dirname(wally.__file__))
195 templ_dir = os.path.join(very_root_dir, 'report_templates')
koder aka kdanilovf86d7af2015-05-06 04:01:54 +0300196 templ_file = os.path.join(templ_dir, templ_name)
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300197 return open(templ_file, 'r').read()
koder aka kdanilov209e85d2015-04-27 23:11:05 +0300198
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300199
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300200def group_by(data, func):
201 if len(data) < 2:
202 yield data
203 return
204
205 ndata = [(func(dt), dt) for dt in data]
206 ndata.sort(key=func)
207 pkey, dt = ndata[0]
208 curr_list = [dt]
209
210 for key, val in ndata[1:]:
211 if pkey != key:
212 yield curr_list
213 curr_list = [val]
214 else:
215 curr_list.append(val)
216 pkey = key
217
218 yield curr_list
219
220
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300221@report('linearity', 'linearity_test')
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300222def linearity_report(processed_results, lab_info, comment):
223 labels_and_data_mp = collections.defaultdict(lambda: [])
224 vls = {}
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300225
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300226 # plot io_time = func(bsize)
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300227 for res in processed_results.values():
228 if res.name.startswith('linearity_test'):
229 iotimes = [1000. / val for val in res.iops.raw]
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300230
231 op_summ = get_test_summary(res.params)[:3]
232
233 labels_and_data_mp[op_summ].append(
234 [res.p.blocksize, res.iops.raw, iotimes])
235
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300236 cvls = res.params.vals.copy()
237 del cvls['blocksize']
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300238 del cvls['rw']
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300239
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300240 cvls.pop('sync', None)
241 cvls.pop('direct', None)
242 cvls.pop('buffered', None)
243
244 if op_summ not in vls:
245 vls[op_summ] = cvls
246 else:
247 assert cvls == vls[op_summ]
248
249 all_labels = None
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300250 _, ax1 = plt.subplots()
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300251 for name, labels_and_data in labels_and_data_mp.items():
252 labels_and_data.sort(key=lambda x: ssize2b(x[0]))
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300253
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300254 labels, _, iotimes = zip(*labels_and_data)
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300255
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300256 if all_labels is None:
257 all_labels = labels
258 else:
259 assert all_labels == labels
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300260
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300261 plt.boxplot(iotimes)
262 if len(labels_and_data) > 2 and \
263 ssize2b(labels_and_data[-2][0]) >= 4096:
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300264
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300265 xt = range(1, len(labels) + 1)
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300266
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300267 def io_time(sz, bw, initial_lat):
268 return sz / bw + initial_lat
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300269
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300270 x = numpy.array(map(ssize2b, labels))
271 y = numpy.array([sum(dt) / len(dt) for dt in iotimes])
272 popt, _ = scipy.optimize.curve_fit(io_time, x, y, p0=(100., 1.))
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300273
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300274 y1 = io_time(x, *popt)
275 plt.plot(xt, y1, linestyle='--',
276 label=name + ' LS linear approx')
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300277
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300278 for idx, (sz, _, _) in enumerate(labels_and_data):
279 if ssize2b(sz) >= 4096:
280 break
281
282 bw = (x[-1] - x[idx]) / (y[-1] - y[idx])
283 lat = y[-1] - x[-1] / bw
284 y2 = io_time(x, bw, lat)
285 plt.plot(xt, y2, linestyle='--',
286 label=abbv_name_to_full(name) +
287 ' (4k & max) linear approx')
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300288
289 plt.setp(ax1, xticklabels=labels)
290
291 plt.xlabel("Block size")
292 plt.ylabel("IO time, ms")
293
koder aka kdanilovfd2cfa52015-05-20 03:17:42 +0300294 plt.subplots_adjust(top=0.85)
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300295 plt.legend(bbox_to_anchor=(0.5, 1.15),
296 loc='upper center',
297 prop={'size': 10}, ncol=2)
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300298 plt.grid()
299 iotime_plot = get_emb_data_svg(plt)
koder aka kdanilovfd2cfa52015-05-20 03:17:42 +0300300 plt.clf()
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300301
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300302 # plot IOPS = func(bsize)
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300303 _, ax1 = plt.subplots()
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300304
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300305 for name, labels_and_data in labels_and_data_mp.items():
306 labels_and_data.sort(key=lambda x: ssize2b(x[0]))
307 _, data, _ = zip(*labels_and_data)
308 plt.boxplot(data)
309 avg = [float(sum(arr)) / len(arr) for arr in data]
310 xt = range(1, len(data) + 1)
311 plt.plot(xt, avg, linestyle='--',
312 label=abbv_name_to_full(name) + " avg")
313
314 plt.setp(ax1, xticklabels=labels)
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300315 plt.xlabel("Block size")
316 plt.ylabel("IOPS")
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300317 plt.legend(bbox_to_anchor=(0.5, 1.15),
318 loc='upper center',
319 prop={'size': 10}, ncol=2)
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300320 plt.grid()
koder aka kdanilovfd2cfa52015-05-20 03:17:42 +0300321 plt.subplots_adjust(top=0.85)
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300322
323 iops_plot = get_emb_data_svg(plt)
324
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300325 res = set(get_test_lcheck_params(res) for res in processed_results.values())
326 ncount = list(set(res.testnodes_count for res in processed_results.values()))
327 conc = list(set(res.concurence for res in processed_results.values()))
328
329 assert len(conc) == 1
330 assert len(ncount) == 1
331
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300332 descr = {
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300333 'vm_count': ncount[0],
334 'concurence': conc[0],
335 'oper_descr': ", ".join(res).capitalize()
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300336 }
337
338 params_map = {'iotime_vs_size': iotime_plot,
339 'iops_vs_size': iops_plot,
340 'descr': descr}
341
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300342 return get_template('report_linearity.html').format(**params_map)
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300343
344
345@report('lat_vs_iops', 'lat_vs_iops')
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300346def lat_vs_iops(processed_results, lab_info, comment):
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300347 lat_iops = collections.defaultdict(lambda: [])
koder aka kdanilovfd2cfa52015-05-20 03:17:42 +0300348 requsted_vs_real = collections.defaultdict(lambda: {})
349
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300350 for res in processed_results.values():
351 if res.name.startswith('lat_vs_iops'):
352 lat_iops[res.concurence].append((res.lat.average / 1000.0,
353 res.lat.deviation / 1000.0,
354 res.iops.average,
355 res.iops.deviation))
koder aka kdanilovfd2cfa52015-05-20 03:17:42 +0300356 requested_iops = res.p.rate_iops * res.concurence
357 requsted_vs_real[res.concurence][requested_iops] = \
358 (res.iops.average, res.iops.deviation)
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300359
koder aka kdanilovfd2cfa52015-05-20 03:17:42 +0300360 colors = ['red', 'green', 'blue', 'orange', 'magenta', "teal"]
361 colors_it = iter(colors)
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300362 for conc, lat_iops in sorted(lat_iops.items()):
363 lat, dev, iops, iops_dev = zip(*lat_iops)
364 plt.errorbar(iops, lat, xerr=iops_dev, yerr=dev, fmt='ro',
365 label=str(conc) + " threads",
koder aka kdanilovfd2cfa52015-05-20 03:17:42 +0300366 color=next(colors_it))
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300367
368 plt.xlabel("IOPS")
369 plt.ylabel("Latency, ms")
370 plt.grid()
371 plt.legend(loc=0)
koder aka kdanilovfd2cfa52015-05-20 03:17:42 +0300372 plt_iops_vs_lat = get_emb_data_svg(plt)
373 plt.clf()
374
375 colors_it = iter(colors)
376 for conc, req_vs_real in sorted(requsted_vs_real.items()):
377 req, real = zip(*sorted(req_vs_real.items()))
378 iops, dev = zip(*real)
379 plt.errorbar(req, iops, yerr=dev, fmt='ro',
380 label=str(conc) + " threads",
381 color=next(colors_it))
382 plt.xlabel("Requested IOPS")
383 plt.ylabel("Get IOPS")
384 plt.grid()
385 plt.legend(loc=0)
386 plt_iops_vs_requested = get_emb_data_svg(plt)
387
388 res1 = processed_results.values()[0]
389 params_map = {'iops_vs_lat': plt_iops_vs_lat,
390 'iops_vs_requested': plt_iops_vs_requested,
391 'oper_descr': get_test_lcheck_params(res1).capitalize()}
392
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300393 return get_template('report_iops_vs_lat.html').format(**params_map)
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300394
395
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300396def render_all_html(comment, info, lab_description, images, templ_name):
koder aka kdanilovf86d7af2015-05-06 04:01:54 +0300397 data = info.__dict__.copy()
398 for name, val in data.items():
koder aka kdanilov209e85d2015-04-27 23:11:05 +0300399 if not name.startswith('__'):
koder aka kdanilovc368eb62015-04-28 18:22:01 +0300400 if val is None:
koder aka kdanilovf86d7af2015-05-06 04:01:54 +0300401 data[name] = '-'
402 elif isinstance(val, (int, float, long)):
403 data[name] = round_3_digit(val)
koder aka kdanilov209e85d2015-04-27 23:11:05 +0300404
koder aka kdanilovf86d7af2015-05-06 04:01:54 +0300405 data['bw_read_max'] = (data['bw_read_max'][0] // 1024,
406 data['bw_read_max'][1])
407 data['bw_write_max'] = (data['bw_write_max'][0] // 1024,
408 data['bw_write_max'][1])
koder aka kdanilov7e0f7cf2015-05-01 17:24:35 +0300409
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300410 images.update(data)
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300411 return get_template(templ_name).format(lab_info=lab_description,
412 comment=comment,
413 **images)
koder aka kdanilovcff7b2e2015-04-18 20:48:15 +0300414
415
koder aka kdanilovf86d7af2015-05-06 04:01:54 +0300416def io_chart(title, concurence,
417 latv, latv_min, latv_max,
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300418 iops_or_bw, iops_or_bw_err,
419 legend, log=False,
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300420 boxplots=False,
421 latv_50=None, latv_95=None):
koder aka kdanilovd5ed4da2015-05-07 23:33:23 +0300422 points = " MiBps" if legend == 'BW' else ""
423 lc = len(concurence)
424 width = 0.35
425 xt = range(1, lc + 1)
426
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300427 op_per_vm = [v / (vm * th) for v, (vm, th) in zip(iops_or_bw, concurence)]
koder aka kdanilovd5ed4da2015-05-07 23:33:23 +0300428 fig, p1 = plt.subplots()
429 xpos = [i - width / 2 for i in xt]
430
koder aka kdanilov416b87a2015-05-12 00:26:04 +0300431 p1.bar(xpos, iops_or_bw,
432 width=width,
433 yerr=iops_or_bw_err,
434 ecolor='m',
koder aka kdanilovd5ed4da2015-05-07 23:33:23 +0300435 color='y',
436 label=legend)
437
koder aka kdanilovd5ed4da2015-05-07 23:33:23 +0300438 p1.grid(True)
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300439 p1.plot(xt, op_per_vm, '--', label=legend + "/thread", color='black')
koder aka kdanilov416b87a2015-05-12 00:26:04 +0300440 handles1, labels1 = p1.get_legend_handles_labels()
koder aka kdanilovd5ed4da2015-05-07 23:33:23 +0300441
442 p2 = p1.twinx()
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300443
444 if latv_50 is None:
445 p2.plot(xt, latv_max, label="lat max")
446 p2.plot(xt, latv, label="lat avg")
447 p2.plot(xt, latv_min, label="lat min")
448 else:
449 p2.plot(xt, latv_50, label="lat med")
450 p2.plot(xt, latv_95, label="lat 95%")
koder aka kdanilovd5ed4da2015-05-07 23:33:23 +0300451
452 plt.xlim(0.5, lc + 0.5)
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300453 plt.xticks(xt, ["{0} * {1}".format(vm, th) for (vm, th) in concurence])
454 p1.set_xlabel("VM Count * Thread per VM")
koder aka kdanilovd5ed4da2015-05-07 23:33:23 +0300455 p1.set_ylabel(legend + points)
456 p2.set_ylabel("Latency ms")
457 plt.title(title)
koder aka kdanilov416b87a2015-05-12 00:26:04 +0300458 handles2, labels2 = p2.get_legend_handles_labels()
459
460 plt.legend(handles1 + handles2, labels1 + labels2,
461 loc='center left', bbox_to_anchor=(1.1, 0.81))
koder aka kdanilov416b87a2015-05-12 00:26:04 +0300462
463 if log:
464 p1.set_yscale('log')
465 p2.set_yscale('log')
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300466 plt.subplots_adjust(right=0.68)
467
468 return get_emb_data_svg(plt)
koder aka kdanilovd5ed4da2015-05-07 23:33:23 +0300469
470
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300471def make_plots(processed_results, plots):
472 files = {}
koder aka kdanilov63ad2062015-04-27 13:11:40 +0300473 for name_pref, fname, desc in plots:
koder aka kdanilov4a510ee2015-04-21 18:50:42 +0300474 chart_data = []
koder aka kdanilov63ad2062015-04-27 13:11:40 +0300475
koder aka kdanilov4a510ee2015-04-21 18:50:42 +0300476 for res in processed_results.values():
477 if res.name.startswith(name_pref):
478 chart_data.append(res)
479
koder aka kdanilov63ad2062015-04-27 13:11:40 +0300480 if len(chart_data) == 0:
481 raise ValueError("Can't found any date for " + name_pref)
482
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300483 use_bw = ssize2b(chart_data[0].p.blocksize) > 16 * 1024
koder aka kdanilov63ad2062015-04-27 13:11:40 +0300484
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300485 chart_data.sort(key=lambda x: x.concurence)
koder aka kdanilov4a510ee2015-04-21 18:50:42 +0300486
koder aka kdanilovf86d7af2015-05-06 04:01:54 +0300487 # if x.lat.average < max_lat]
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300488 # lat = [x.lat.average / 1000 for x in chart_data]
489 # lat_min = [x.lat.min / 1000 for x in chart_data]
490 # lat_max = [x.lat.max / 1000 for x in chart_data]
491 lat = None
492 lat_min = None
493 lat_max = None
494 lat_50 = [x.lat_50 for x in chart_data]
495 lat_95 = [x.lat_95 for x in chart_data]
koder aka kdanilovf86d7af2015-05-06 04:01:54 +0300496
koder aka kdanilov416b87a2015-05-12 00:26:04 +0300497 testnodes_count = x.testnodes_count
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300498 concurence = [(testnodes_count, x.concurence)
koder aka kdanilov416b87a2015-05-12 00:26:04 +0300499 for x in chart_data]
koder aka kdanilov4a510ee2015-04-21 18:50:42 +0300500
koder aka kdanilov63ad2062015-04-27 13:11:40 +0300501 if use_bw:
koder aka kdanilovf86d7af2015-05-06 04:01:54 +0300502 data = [x.bw.average / 1000 for x in chart_data]
503 data_dev = [x.bw.confidence / 1000 for x in chart_data]
koder aka kdanilov63ad2062015-04-27 13:11:40 +0300504 name = "BW"
505 else:
koder aka kdanilovf86d7af2015-05-06 04:01:54 +0300506 data = [x.iops.average for x in chart_data]
507 data_dev = [x.iops.confidence for x in chart_data]
koder aka kdanilov63ad2062015-04-27 13:11:40 +0300508 name = "IOPS"
509
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300510 fc = io_chart(title=desc,
511 concurence=concurence,
512 latv=lat, latv_min=lat_min, latv_max=lat_max,
513 iops_or_bw=data,
514 iops_or_bw_err=data_dev,
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300515 legend=name, latv_50=lat_50, latv_95=lat_95)
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300516 files[fname] = fc
517
518 return files
koder aka kdanilov4a510ee2015-04-21 18:50:42 +0300519
520
koder aka kdanilov7e0f7cf2015-05-01 17:24:35 +0300521def find_max_where(processed_results, sync_mode, blocksize, rw, iops=True):
koder aka kdanilovf86d7af2015-05-06 04:01:54 +0300522 result = None
koder aka kdanilov7e0f7cf2015-05-01 17:24:35 +0300523 attr = 'iops' if iops else 'bw'
524 for measurement in processed_results.values():
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300525 ok = measurement.sync_mode == sync_mode
526 ok = ok and (measurement.p.blocksize == blocksize)
527 ok = ok and (measurement.p.rw == rw)
koder aka kdanilov7e0f7cf2015-05-01 17:24:35 +0300528
529 if ok:
koder aka kdanilovf86d7af2015-05-06 04:01:54 +0300530 field = getattr(measurement, attr)
531
532 if result is None:
533 result = field
534 elif field.average > result.average:
535 result = field
536
koder aka kdanilov7e0f7cf2015-05-01 17:24:35 +0300537 return result
538
539
koder aka kdanilov4a510ee2015-04-21 18:50:42 +0300540def get_disk_info(processed_results):
541 di = DiskInfo()
koder aka kdanilov7e0f7cf2015-05-01 17:24:35 +0300542 di.direct_iops_w_max = find_max_where(processed_results,
543 'd', '4k', 'randwrite')
544 di.direct_iops_r_max = find_max_where(processed_results,
545 'd', '4k', 'randread')
koder aka kdanilovf86d7af2015-05-06 04:01:54 +0300546
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300547 di.direct_iops_w64_max = find_max_where(processed_results,
548 'd', '64k', 'randwrite')
549
550 for sz in ('16m', '64m'):
551 di.bw_write_max = find_max_where(processed_results,
552 'd', sz, 'randwrite', False)
553 if di.bw_write_max is not None:
554 break
555
koder aka kdanilovf86d7af2015-05-06 04:01:54 +0300556 if di.bw_write_max is None:
557 di.bw_write_max = find_max_where(processed_results,
558 'd', '1m', 'write', False)
559
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300560 for sz in ('16m', '64m'):
561 di.bw_read_max = find_max_where(processed_results,
562 'd', sz, 'randread', False)
563 if di.bw_read_max is not None:
564 break
565
koder aka kdanilovf86d7af2015-05-06 04:01:54 +0300566 if di.bw_read_max is None:
567 di.bw_read_max = find_max_where(processed_results,
568 'd', '1m', 'read', False)
koder aka kdanilov7e0f7cf2015-05-01 17:24:35 +0300569
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300570 rws4k_iops_lat_th = []
koder aka kdanilov4a510ee2015-04-21 18:50:42 +0300571 for res in processed_results.values():
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300572 if res.sync_mode in 'xs' and res.p.blocksize == '4k':
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300573 if res.p.rw != 'randwrite':
koder aka kdanilov4a510ee2015-04-21 18:50:42 +0300574 continue
koder aka kdanilovf86d7af2015-05-06 04:01:54 +0300575 rws4k_iops_lat_th.append((res.iops.average,
576 res.lat.average,
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300577 res.concurence))
koder aka kdanilov4a510ee2015-04-21 18:50:42 +0300578
koder aka kdanilov4a510ee2015-04-21 18:50:42 +0300579 rws4k_iops_lat_th.sort(key=lambda (_1, _2, conc): conc)
580
581 latv = [lat for _, lat, _ in rws4k_iops_lat_th]
582
583 for tlatv_ms in [10, 30, 100]:
584 tlat = tlatv_ms * 1000
585 pos = bisect.bisect_left(latv, tlat)
586 if 0 == pos:
koder aka kdanilovbb5fe072015-05-21 02:50:23 +0300587 setattr(di, 'rws4k_{}ms'.format(tlatv_ms), 0)
koder aka kdanilov4a510ee2015-04-21 18:50:42 +0300588 elif pos == len(latv):
koder aka kdanilovbb5fe072015-05-21 02:50:23 +0300589 iops3, _, _ = rws4k_iops_lat_th[-1]
590 setattr(di, 'rws4k_{}ms'.format(tlatv_ms), ">=" + str(iops3))
koder aka kdanilov4a510ee2015-04-21 18:50:42 +0300591 else:
592 lat1 = latv[pos - 1]
593 lat2 = latv[pos]
594
koder aka kdanilovf86d7af2015-05-06 04:01:54 +0300595 iops1, _, th1 = rws4k_iops_lat_th[pos - 1]
596 iops2, _, th2 = rws4k_iops_lat_th[pos]
koder aka kdanilov4a510ee2015-04-21 18:50:42 +0300597
598 th_lat_coef = (th2 - th1) / (lat2 - lat1)
599 th3 = th_lat_coef * (tlat - lat1) + th1
600
601 th_iops_coef = (iops2 - iops1) / (th2 - th1)
602 iops3 = th_iops_coef * (th3 - th1) + iops1
koder aka kdanilovbb5fe072015-05-21 02:50:23 +0300603 setattr(di, 'rws4k_{}ms'.format(tlatv_ms), int(iops3))
koder aka kdanilov4a510ee2015-04-21 18:50:42 +0300604
605 hdi = DiskInfo()
koder aka kdanilov7e0f7cf2015-05-01 17:24:35 +0300606
607 def pp(x):
koder aka kdanilovf86d7af2015-05-06 04:01:54 +0300608 med, conf = x.rounded_average_conf()
609 conf_perc = int(float(conf) / med * 100)
610 return (med, conf_perc)
koder aka kdanilov7e0f7cf2015-05-01 17:24:35 +0300611
612 hdi.direct_iops_r_max = pp(di.direct_iops_r_max)
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300613
614 if di.direct_iops_w_max is not None:
615 hdi.direct_iops_w_max = pp(di.direct_iops_w_max)
616 else:
617 hdi.direct_iops_w_max = None
618
619 if di.direct_iops_w64_max is not None:
620 hdi.direct_iops_w64_max = pp(di.direct_iops_w64_max)
621 else:
622 hdi.direct_iops_w64_max = None
623
koder aka kdanilov7e0f7cf2015-05-01 17:24:35 +0300624 hdi.bw_write_max = pp(di.bw_write_max)
625 hdi.bw_read_max = pp(di.bw_read_max)
626
koder aka kdanilovc368eb62015-04-28 18:22:01 +0300627 hdi.rws4k_10ms = di.rws4k_10ms if 0 != di.rws4k_10ms else None
628 hdi.rws4k_30ms = di.rws4k_30ms if 0 != di.rws4k_30ms else None
629 hdi.rws4k_100ms = di.rws4k_100ms if 0 != di.rws4k_100ms else None
koder aka kdanilov4a510ee2015-04-21 18:50:42 +0300630 return hdi
631
632
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300633@report('hdd', 'hdd')
634def make_hdd_report(processed_results, lab_info, comment):
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300635 plots = [
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300636 ('hdd_rrd4k', 'rand_read_4k', 'Random read 4k direct IOPS'),
637 ('hdd_rwx4k', 'rand_write_4k', 'Random write 4k sync IOPS')
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300638 ]
639 images = make_plots(processed_results, plots)
koder aka kdanilova4a570f2015-04-23 22:11:40 +0300640 di = get_disk_info(processed_results)
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300641 return render_all_html(comment, di, lab_info, images, "report_hdd.html")
koder aka kdanilov63ad2062015-04-27 13:11:40 +0300642
643
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300644@report('cinder_iscsi', 'cinder_iscsi')
645def make_cinder_iscsi_report(processed_results, lab_info, comment):
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300646 plots = [
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300647 ('cinder_iscsi_rrd4k', 'rand_read_4k', 'Random read 4k direct IOPS'),
648 ('cinder_iscsi_rwx4k', 'rand_write_4k', 'Random write 4k sync IOPS')
649 ]
650 try:
651 images = make_plots(processed_results, plots)
652 except ValueError:
653 plots = [
654 ('cinder_iscsi_rrd4k', 'rand_read_4k', 'Random read 4k direct IOPS'),
655 ('cinder_iscsi_rws4k', 'rand_write_4k', 'Random write 4k sync IOPS')
656 ]
657 images = make_plots(processed_results, plots)
658 di = get_disk_info(processed_results)
659 return render_all_html(comment, di, lab_info, images, "report_cinder_iscsi.html")
660
661
662@report('ceph', 'ceph')
663def make_ceph_report(processed_results, lab_info, comment):
664 plots = [
665 ('ceph_rrd4k', 'rand_read_4k', 'Random read 4k direct IOPS'),
666 ('ceph_rws4k', 'rand_write_4k', 'Random write 4k sync IOPS'),
667 ('ceph_rrd16m', 'rand_read_16m', 'Random read 16m direct MiBps'),
668 ('ceph_rwd16m', 'rand_write_16m',
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300669 'Random write 16m direct MiBps'),
670 ]
671
672 images = make_plots(processed_results, plots)
koder aka kdanilov63ad2062015-04-27 13:11:40 +0300673 di = get_disk_info(processed_results)
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300674 return render_all_html(comment, di, lab_info, images, "report_ceph.html")
koder aka kdanilova4a570f2015-04-23 22:11:40 +0300675
676
koder aka kdanilov7248c7b2015-05-31 22:53:03 +0300677@report('mixed', 'mixed')
678def make_mixed_report(processed_results, lab_info, comment):
679 #
680 # IOPS(X% read) = 100 / ( X / IOPS_W + (100 - X) / IOPS_R )
681 #
682 is_ssd = True
683 mixed = collections.defaultdict(lambda: [])
684 for res in processed_results.values():
685 if res.name.startswith('mixed'):
686 if res.name.startswith('mixed-ssd'):
687 is_ssd = True
688 mixed[res.concurence].append((res.p.rwmixread,
689 res.lat.average / 1000.0,
690 res.lat.deviation / 1000.0,
691 res.iops.average,
692 res.iops.deviation))
693
694 if len(mixed) == 0:
695 raise ValueError("No mixed load found")
696
697 fig, p1 = plt.subplots()
698 p2 = p1.twinx()
699
700 colors = ['red', 'green', 'blue', 'orange', 'magenta', "teal"]
701 colors_it = iter(colors)
702 for conc, mix_lat_iops in sorted(mixed.items()):
703 mix_lat_iops = sorted(mix_lat_iops)
704 read_perc, lat, dev, iops, iops_dev = zip(*mix_lat_iops)
705 p1.errorbar(read_perc, iops, color=next(colors_it),
706 yerr=iops_dev, label=str(conc) + " th")
707
708 p2.errorbar(read_perc, lat, color=next(colors_it),
709 ls='--', yerr=dev, label=str(conc) + " th lat")
710
711 if is_ssd:
712 p1.set_yscale('log')
713 p2.set_yscale('log')
714
715 p1.set_xlim(-5, 105)
716
717 read_perc = set(read_perc)
718 read_perc.add(0)
719 read_perc.add(100)
720 read_perc = sorted(read_perc)
721
722 plt.xticks(read_perc, map(str, read_perc))
723
724 p1.grid(True)
725 p1.set_xlabel("% of reads")
726 p1.set_ylabel("Mixed IOPS")
727 p2.set_ylabel("Latency, ms")
728
729 handles1, labels1 = p1.get_legend_handles_labels()
730 handles2, labels2 = p2.get_legend_handles_labels()
731 plt.subplots_adjust(top=0.85)
732 plt.legend(handles1 + handles2, labels1 + labels2,
733 bbox_to_anchor=(0.5, 1.15),
734 loc='upper center',
735 prop={'size': 12}, ncol=3)
736 plt.show()
737
738
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300739def make_load_report(idx, results_dir, fname):
740 dpath = os.path.join(results_dir, "io_" + str(idx))
741 files = sorted(os.listdir(dpath))
742 gf = lambda x: "_".join(x.rsplit(".", 1)[0].split('_')[:3])
743
744 for key, group in itertools.groupby(files, gf):
745 fname = os.path.join(dpath, key + ".fio")
746
747 cfgs = list(parse_all_in_1(open(fname).read(), fname))
748
749 fname = os.path.join(dpath, key + "_lat.log")
750
751 curr = []
752 arrays = []
753
754 with open(fname) as fd:
755 for offset, lat, _, _ in csv.reader(fd):
756 offset = int(offset)
757 lat = int(lat)
758 if len(curr) > 0 and curr[-1][0] > offset:
759 arrays.append(curr)
760 curr = []
761 curr.append((offset, lat))
762 arrays.append(curr)
763 conc = int(cfgs[0].vals.get('numjobs', 1))
764
765 if conc != 5:
766 continue
767
768 assert len(arrays) == len(cfgs) * conc
769
770 garrays = [[(0, 0)] for _ in range(conc)]
771
772 for offset in range(len(cfgs)):
773 for acc, new_arr in zip(garrays, arrays[offset * conc:(offset + 1) * conc]):
774 last = acc[-1][0]
775 for off, lat in new_arr:
776 acc.append((off / 1000. + last, lat / 1000.))
777
778 for cfg, arr in zip(cfgs, garrays):
779 plt.plot(*zip(*arr[1:]))
780 plt.show()
781 exit(1)
782
783
784def make_io_report(dinfo, comment, path, lab_info=None):
koder aka kdanilovf86d7af2015-05-06 04:01:54 +0300785 lab_info = {
786 "total_disk": "None",
787 "total_memory": "None",
788 "nodes_count": "None",
789 "processor_count": "None"
790 }
koder aka kdanilovcff7b2e2015-04-18 20:48:15 +0300791
koder aka kdanilova047e1b2015-04-21 23:16:59 +0300792 try:
koder aka kdanilov4af1c1d2015-05-18 15:48:58 +0300793 res_fields = sorted(v.name for v in dinfo.values())
794
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300795 found = False
koder aka kdanilov57ce4db2015-04-25 21:25:51 +0300796 for fields, name, func in report_funcs:
koder aka kdanilovafd98742015-04-24 01:27:22 +0300797 for field in fields:
koder aka kdanilov57ce4db2015-04-25 21:25:51 +0300798 pos = bisect.bisect_left(res_fields, field)
799
800 if pos == len(res_fields):
koder aka kdanilov63ad2062015-04-27 13:11:40 +0300801 break
koder aka kdanilov57ce4db2015-04-25 21:25:51 +0300802
koder aka kdanilovbe8f89f2015-04-28 14:51:51 +0300803 if not res_fields[pos].startswith(field):
koder aka kdanilovafd98742015-04-24 01:27:22 +0300804 break
805 else:
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300806 found = True
koder aka kdanilov57ce4db2015-04-25 21:25:51 +0300807 hpath = path.format(name)
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300808
809 try:
810 report = func(dinfo, lab_info, comment)
811 except:
812 logger.exception("Diring {0} report generation".format(name))
813 continue
814
koder aka kdanilov7248c7b2015-05-31 22:53:03 +0300815 if report is not None:
816 try:
817 with open(hpath, "w") as fd:
818 fd.write(report)
819 except:
820 logger.exception("Diring saving {0} report".format(name))
821 continue
822 logger.info("Report {0} saved into {1}".format(name, hpath))
823 else:
824 logger.warning("No report produced by {0!r}".format(name))
koder aka kdanilov88407ff2015-05-26 15:35:57 +0300825
826 if not found:
koder aka kdanilova4a570f2015-04-23 22:11:40 +0300827 logger.warning("No report generator found for this load")
koder aka kdanilovafd98742015-04-24 01:27:22 +0300828
koder aka kdanilova047e1b2015-04-21 23:16:59 +0300829 except Exception as exc:
koder aka kdanilov57ce4db2015-04-25 21:25:51 +0300830 import traceback
831 traceback.print_exc()
koder aka kdanilovec1b9732015-04-23 20:43:29 +0300832 logger.error("Failed to generate html report:" + str(exc))