koder aka kdanilov | cff7b2e | 2015-04-18 20:48:15 +0300 | [diff] [blame] | 1 | import os |
| 2 | import sys |
koder aka kdanilov | 4a510ee | 2015-04-21 18:50:42 +0300 | [diff] [blame^] | 3 | import bisect |
koder aka kdanilov | cff7b2e | 2015-04-18 20:48:15 +0300 | [diff] [blame] | 4 | |
koder aka kdanilov | 4a510ee | 2015-04-21 18:50:42 +0300 | [diff] [blame^] | 5 | import wally |
koder aka kdanilov | cff7b2e | 2015-04-18 20:48:15 +0300 | [diff] [blame] | 6 | from wally import charts |
koder aka kdanilov | cff7b2e | 2015-04-18 20:48:15 +0300 | [diff] [blame] | 7 | from wally.utils import parse_creds |
koder aka kdanilov | cff7b2e | 2015-04-18 20:48:15 +0300 | [diff] [blame] | 8 | from wally.meta_info import total_lab_info, collect_lab_data |
| 9 | |
koder aka kdanilov | 4a510ee | 2015-04-21 18:50:42 +0300 | [diff] [blame^] | 10 | from wally.suits.io.results_loader import process_disk_info |
koder aka kdanilov | cff7b2e | 2015-04-18 20:48:15 +0300 | [diff] [blame] | 11 | |
koder aka kdanilov | 4a510ee | 2015-04-21 18:50:42 +0300 | [diff] [blame^] | 12 | |
| 13 | def render_html(dest, info, lab_description): |
| 14 | very_root_dir = os.path.dirname(os.path.dirname(wally.__file__)) |
| 15 | templ_dir = os.path.join(very_root_dir, 'report_templates') |
| 16 | templ_file = os.path.join(templ_dir, "report.html") |
| 17 | templ = open(templ_file, 'r').read() |
| 18 | report = templ.format(lab_info=lab_description, **info.__dict__) |
| 19 | open(dest, 'w').write(report) |
koder aka kdanilov | cff7b2e | 2015-04-18 20:48:15 +0300 | [diff] [blame] | 20 | |
| 21 | |
| 22 | def io_chart(title, concurence, latv, iops_or_bw, iops_or_bw_dev, |
| 23 | legend, fname): |
| 24 | bar_data, bar_dev = iops_or_bw, iops_or_bw_dev |
| 25 | legend = [legend] |
| 26 | |
| 27 | iops_or_bw_per_vm = [] |
| 28 | for i in range(len(concurence)): |
| 29 | iops_or_bw_per_vm.append(iops_or_bw[i] / concurence[i]) |
| 30 | |
| 31 | bar_dev_bottom = [] |
| 32 | bar_dev_top = [] |
| 33 | for i in range(len(bar_data)): |
| 34 | bar_dev_top.append(bar_data[i] + bar_dev[i]) |
| 35 | bar_dev_bottom.append(bar_data[i] - bar_dev[i]) |
| 36 | |
| 37 | latv = [lat / 1000 for lat in latv] |
| 38 | ch = charts.render_vertical_bar(title, legend, [bar_data], [bar_dev_top], |
| 39 | [bar_dev_bottom], file_name=fname, |
| 40 | scale_x=concurence, |
| 41 | lines=[ |
| 42 | (latv, "msec", "rr", "lat"), |
| 43 | (iops_or_bw_per_vm, None, None, |
| 44 | "bw_per_vm") |
| 45 | ]) |
| 46 | return str(ch) |
| 47 | |
| 48 | |
koder aka kdanilov | 4a510ee | 2015-04-21 18:50:42 +0300 | [diff] [blame^] | 49 | def make_plots(processed_results, path): |
| 50 | name_filters = [ |
| 51 | ('hdd_test_rrd4k', ('concurence', 'lat', 'iops'), |
| 52 | 'rand_read_4k', 'Random read 4k sync'), |
| 53 | ('hdd_test_rws4k', ('concurence', 'lat', 'iops'), |
| 54 | 'rand_write_4k', 'Random write 4k sync') |
| 55 | ] |
| 56 | |
| 57 | for name_pref, _, fname, desc in name_filters: |
| 58 | chart_data = [] |
| 59 | for res in processed_results.values(): |
| 60 | if res.name.startswith(name_pref): |
| 61 | chart_data.append(res) |
| 62 | |
| 63 | chart_data.sort(key=lambda x: x.raw['concurence']) |
| 64 | |
| 65 | lat = [x.lat for x in chart_data] |
| 66 | concurence = [x.raw['concurence'] for x in chart_data] |
| 67 | bw = [x.bw for x in chart_data] |
| 68 | bw_dev = [x.dev * x.bw for x in chart_data] |
| 69 | |
| 70 | io_chart(desc, concurence, lat, bw, bw_dev, 'bw', fname) |
| 71 | |
| 72 | |
| 73 | class DiskInfo(object): |
| 74 | def __init__(self): |
| 75 | self.direct_iops_r_max = 0 |
| 76 | self.direct_iops_w_max = 0 |
| 77 | self.rws4k_10ms = 0 |
| 78 | self.rws4k_30ms = 0 |
| 79 | self.rws4k_100ms = 0 |
| 80 | self.bw_write_max = 0 |
| 81 | self.bw_read_max = 0 |
| 82 | |
| 83 | |
| 84 | def get_disk_info(processed_results): |
| 85 | di = DiskInfo() |
| 86 | rws4k_iops_lat_th = [] |
| 87 | |
| 88 | for res in processed_results.values(): |
| 89 | if res.raw['sync_mode'] == 'd' and res.raw['blocksize'] == '4k': |
| 90 | if res.raw['rw'] == 'randwrite': |
| 91 | di.direct_iops_w_max = max(di.direct_iops_w_max, res.iops) |
| 92 | elif res.raw['rw'] == 'randread': |
| 93 | di.direct_iops_r_max = max(di.direct_iops_r_max, res.iops) |
| 94 | elif res.raw['sync_mode'] == 's' and res.raw['blocksize'] == '4k': |
| 95 | if res.raw['rw'] != 'randwrite': |
| 96 | continue |
| 97 | |
| 98 | rws4k_iops_lat_th.append((res.iops, res.lat, |
| 99 | res.raw['concurence'])) |
| 100 | |
| 101 | elif res.raw['sync_mode'] == 'd' and res.raw['blocksize'] == '1m': |
| 102 | |
| 103 | if res.raw['rw'] == 'write': |
| 104 | di.bw_write_max = max(di.bw_write_max, res.bw) |
| 105 | elif res.raw['rw'] == 'read': |
| 106 | di.bw_read_max = max(di.bw_read_max, res.bw) |
| 107 | |
| 108 | di.bw_write_max /= 1000 |
| 109 | di.bw_read_max /= 1000 |
| 110 | |
| 111 | rws4k_iops_lat_th.sort(key=lambda (_1, _2, conc): conc) |
| 112 | |
| 113 | latv = [lat for _, lat, _ in rws4k_iops_lat_th] |
| 114 | |
| 115 | for tlatv_ms in [10, 30, 100]: |
| 116 | tlat = tlatv_ms * 1000 |
| 117 | pos = bisect.bisect_left(latv, tlat) |
| 118 | if 0 == pos: |
| 119 | iops3 = 0 |
| 120 | elif pos == len(latv): |
| 121 | iops3 = latv[-1] |
| 122 | else: |
| 123 | lat1 = latv[pos - 1] |
| 124 | lat2 = latv[pos] |
| 125 | |
| 126 | th1 = rws4k_iops_lat_th[pos - 1][2] |
| 127 | th2 = rws4k_iops_lat_th[pos][2] |
| 128 | |
| 129 | iops1 = rws4k_iops_lat_th[pos - 1][0] |
| 130 | iops2 = rws4k_iops_lat_th[pos][0] |
| 131 | |
| 132 | th_lat_coef = (th2 - th1) / (lat2 - lat1) |
| 133 | th3 = th_lat_coef * (tlat - lat1) + th1 |
| 134 | |
| 135 | th_iops_coef = (iops2 - iops1) / (th2 - th1) |
| 136 | iops3 = th_iops_coef * (th3 - th1) + iops1 |
| 137 | setattr(di, 'rws4k_{}ms'.format(tlatv_ms), int(iops3)) |
| 138 | |
| 139 | hdi = DiskInfo() |
| 140 | hdi.direct_iops_r_max = di.direct_iops_r_max |
| 141 | hdi.direct_iops_w_max = di.direct_iops_w_max |
| 142 | hdi.rws4k_10ms = di.rws4k_10ms if 0 != di.rws4k_10ms else '-' |
| 143 | hdi.rws4k_30ms = di.rws4k_30ms if 0 != di.rws4k_30ms else '-' |
| 144 | hdi.rws4k_100ms = di.rws4k_100ms if 0 != di.rws4k_100ms else '-' |
| 145 | hdi.bw_write_max = di.bw_write_max |
| 146 | hdi.bw_read_max = di.bw_read_max |
| 147 | return hdi |
| 148 | |
| 149 | |
koder aka kdanilov | cff7b2e | 2015-04-18 20:48:15 +0300 | [diff] [blame] | 150 | def make_io_report(results, path, lab_url=None, creds=None): |
| 151 | if lab_url is not None: |
| 152 | username, password, tenant_name = parse_creds(creds) |
| 153 | creds = {'username': username, |
| 154 | 'password': password, |
| 155 | "tenant_name": tenant_name} |
| 156 | data = collect_lab_data(lab_url, creds) |
| 157 | lab_info = total_lab_info(data) |
| 158 | else: |
koder aka kdanilov | 4a510ee | 2015-04-21 18:50:42 +0300 | [diff] [blame^] | 159 | lab_info = { |
| 160 | "total_disk": "None", |
| 161 | "total_memory": "None", |
| 162 | "nodes_count": "None", |
| 163 | "processor_count": "None" |
| 164 | } |
koder aka kdanilov | cff7b2e | 2015-04-18 20:48:15 +0300 | [diff] [blame] | 165 | |
koder aka kdanilov | 4a510ee | 2015-04-21 18:50:42 +0300 | [diff] [blame^] | 166 | processed_results = process_disk_info(results) |
| 167 | make_plots(processed_results, path) |
| 168 | di = get_disk_info(processed_results) |
| 169 | render_html(path, di, lab_info) |
koder aka kdanilov | cff7b2e | 2015-04-18 20:48:15 +0300 | [diff] [blame] | 170 | |
| 171 | |
| 172 | def main(args): |
| 173 | make_io_report(results=[('a', 'b')], |
| 174 | path=os.path.dirname(args[0]), |
| 175 | lab_url='http://172.16.52.112:8000', |
| 176 | creds='admin:admin@admin') |
| 177 | return 0 |
| 178 | |
| 179 | |
| 180 | if __name__ == '__main__': |
| 181 | exit(main(sys.argv)) |