From 51ab2aeda3c0ee94303a626c072b46f391ebdf97 Mon Sep 17 00:00:00 2001 From: Christopher Kenna Date: Fri, 14 Oct 2011 01:34:59 -0400 Subject: Include level-A release times with regular release times. Our paper includes level-A metrics in the overall scheduling overhead metrics, so we need to manually add them back in for releases since they take a different code path in the kernel. --- plot_rtas12.py | 102 ++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 87 insertions(+), 15 deletions(-) (limited to 'plot_rtas12.py') diff --git a/plot_rtas12.py b/plot_rtas12.py index aeba823..c248b95 100755 --- a/plot_rtas12.py +++ b/plot_rtas12.py @@ -1,10 +1,13 @@ #!/usr/bin/env python import sys +import time from os.path import basename from os import listdir +from tempfile import NamedTemporaryFile as Tmp + from plot import decode, Plot from gnuplot import curve @@ -41,16 +44,16 @@ def gnuplot_col(col_name): return 1 + COLS[col_name] def get_sched_title(sched): - SCHEDULERS = {'MC': 'MC', - 'MC-MERGE': 'MC + MT', - 'MC-MERGE-REDIR': 'MC + MT + REDIR'} + SCHEDULERS = {'MC': 'Basic', + 'MC-MERGE': 'IM + TM', + 'MC-MERGE-REDIR': 'IM + TM + WR'} return SCHEDULERS[sched] def get_overhead_title(ov): - OV = {'SCHED': '', - 'LVLA-SCHED': ' level-A', - 'RELEASE': '', - 'LVLA-RELEASE': ' level-A'} + OV = {'SCHED': '(A + B + C)', + 'LVLA-SCHED': '(A)', + 'RELEASE': '(A + B + C)', + 'LVLA-RELEASE': '(A)'} return OV[ov] def set_plot_opts(p): @@ -60,14 +63,18 @@ def set_plot_opts(p): p.size = ('8.5cm', '5.25cm') p.default_style = 'linespoints lw 2.5' p.default_style += ' smooth bezier' - p.key = 'below' + p.key = 'off' p.monochrome = False p.dashed_lines = False p.xrange = (18, 122) + p.yrange = (0, '') for i, c in enumerate(p.curves): c.style = "linespoints ls %d" % (i + 1) + # don't use yellow + p.curves[5].style = "linespoints ls 7" + p.line_styles = [ (1, "lw 1.5 ps 0.3"), (2, "lw 1.5 ps 0.3"), @@ -80,21 +87,87 @@ def set_plot_opts(p): ] +def get_data_matrix(fname): + ret = [] + with open(fname, 'r') as f: + for row in f: + new_row = [] + for field in row.split(','): + s_field = field.strip() + try: + conv = float(s_field) + except ValueError: + conv = s_field + new_row.append(conv) + ret.append(new_row) + return ret + + +def include_level_a_releases(data_dir, o_type, scheduler, ycol): + fmt_f = '{0}/scheduler={1}_overhead={2}.csv' + a_fname = fmt_f.format(data_dir, scheduler, 'LVLA-RELEASE') + b_c_fname = fmt_f.format(data_dir, scheduler, 'RELEASE') + a_data = get_data_matrix(a_fname) + b_c_data = get_data_matrix(b_c_fname) + new_data = [] + + for i, a_row in enumerate(a_data): + b_c_row = b_c_data[i] + # make a copy of a_row + new_row = list(a_row) + if gnuplot_col('max') == ycol: + idx = COLS['max'] + new_row[idx] = max(a_row[idx], b_c_row[idx]) + elif gnuplot_col('avg') == ycol: + avg_col = COLS['avg'] + a_samples = a_row[COLS['samples']] + b_c_samples = b_c_row[COLS['samples']] + a_filtered = a_row[COLS['filtered']] + b_c_filtered = b_c_row[COLS['filtered']] + a_avg = a_row[avg_col] + b_c_avg = b_c_row[avg_col] + n_a = a_samples - a_filtered + n_b_c = b_c_samples - b_c_filtered + new_avg = (a_avg * n_a + b_c_avg * n_b_c) / (n_a + n_b_c) + new_row[avg_col] = new_avg + else: + raise RuntimeError("Don't know how to merge this column.") + new_data.append(new_row) + f = Tmp() + for row in new_data: + f.write(', '.join(map(str, row))) + f.write('\n') + f.file.flush() + return (f.name, f) + + def plot_release(data_dir, ycol, title, fname): p = Plot() p.output = '{0}/{1}'.format(data_dir, fname) p.format = 'pdf' + refs = [] # need to save reference to file handle so it is not deleted for o_type in ['RELEASE', 'LVLA-RELEASE']: for sched in SCHEDULERS: - fname = '{0}/scheduler={1}_overhead={2}.csv'.format(data_dir, sched, o_type) + if o_type == 'RELEASE': + # we have to make the regular release include the level-A + # releases + fname, ref = include_level_a_releases(data_dir, o_type, + sched, ycol) + refs.append(ref) + else: + fname = '{0}/scheduler={1}_overhead={2}.csv'.format(data_dir, sched, o_type) ti = '{0}{1}'.format(get_sched_title(sched), get_overhead_title(o_type)) p.curves += [curve(fname=fname, xcol=gnuplot_col('n_tasks'), ycol=ycol, title=ti)] p.xlabel = 'number of tasks' p.ylabel = 'overhead (microseconds)' - p.title = title set_plot_opts(p) + if ycol == gnuplot_col('max'): + # worst-case release gets the key + p.key = 'top left' + # make the graph tall so the damn key fits + p.yrange = (0, 80) p.gnuplot_exec() def plot_sched(data_dir, ycol, title, fname): @@ -110,7 +183,6 @@ def plot_sched(data_dir, ycol, title, fname): ycol=ycol, title=ti)] p.xlabel = 'number of tasks' p.ylabel = 'overhead (microseconds)' - p.title = title set_plot_opts(p) p.gnuplot_exec() @@ -120,10 +192,10 @@ def main(): usage('missing args') data_dir = sys.argv[1] - plot_sched(data_dir, gnuplot_col('max'), 'worst case scheduling overhead', 'overhead=SCHED_type=MAX.pdf') - plot_release(data_dir, gnuplot_col('max'), 'worst case release overhead', 'overhead=RELEASE_type=MAX.pdf') - plot_sched(data_dir, gnuplot_col('avg'), 'average scheduling overhead', 'overhead=SCHED_type=AVG.pdf') - plot_release(data_dir, gnuplot_col('avg'), 'average release overhead', 'overhead=RELEASE_type=AVG.pdf') + plot_sched(data_dir, gnuplot_col('max'), 'worst-case scheduling overhead', 'overhead=SCHED_type=MAX.pdf') + plot_release(data_dir, gnuplot_col('max'), 'worst-case release overhead', 'overhead=RELEASE_type=MAX.pdf') + plot_sched(data_dir, gnuplot_col('avg'), 'average-case scheduling overhead', 'overhead=SCHED_type=AVG.pdf') + plot_release(data_dir, gnuplot_col('avg'), 'average-case release overhead', 'overhead=RELEASE_type=AVG.pdf') if __name__ == '__main__': main() -- cgit v1.2.2