From aba782a19d3acedff8c81e91839235f2fc6ff404 Mon Sep 17 00:00:00 2001 From: Florian Fischer <florian.fischer@muhq.space> Date: Fri, 8 Apr 2022 09:57:33 +0200 Subject: [PATCH] update plots --- gen_boxplots.py | 91 ++++++++++++++++++++++++++++++++++++++++++++---- muhq-ma-plots.sh | 23 ++++++++---- plots/common.tex | 7 ++++ 3 files changed, 108 insertions(+), 13 deletions(-) create mode 100644 plots/common.tex diff --git a/gen_boxplots.py b/gen_boxplots.py index c61df66..0b9c23f 100755 --- a/gen_boxplots.py +++ b/gen_boxplots.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 """generate boxplots from descriptive stats in yaml""" +import os import sys import typing as T @@ -8,6 +9,72 @@ import yaml Data = dict[str, T.Any] +PLOT_SPECIFICS = { + 'hints': { + 'ylabel': '{latency [us]}', + 'ymax': '300', + 'xmax': '3', + 'xtick': '{1,2}', + 'xticklabels': '{pipe, pipe-no-hints}', + 'title': 'Wakeup Hints', + }, + 'latency': { + 'ymax': '1500', + 'xtick': '{1,2,3}', + 'xticklabels': '{pipe-steal-nc, pipe, pipe-nc}', + 'title': 'Pipe Latency Variants' + }, + 'contention': { + 'ymax': '1100', + 'xtick': '{1,2,3}', + 'xticklabels': '{no-sleep, vanilla}', + 'title': 'Global queue contention' + }, + 'l-vs-ll': { + 'ymax': '1500', + 'xtick': '{1,2,3,4}', + 'xticklabels': '{ll-n-nc, n-nc\\vertPhantom{}, ll-s-nc, s-nc\\vertPhantom{}}', + 'title': ' Lockless vs Locked' + }, + 'n-s-c': { + 'ylabel': '{latency [us]}', + 'ymax': '1300', + 'xtick': '{1,2,3,4}', + 'xticklabels': '{n, n-nc, s, s-nc}', + 'title': 'Additional Completer' + }, + 'n-vs-ns': { + 'ylabel': '{latency [us]}', + 'ymax': '150', + 'xtick': '{1,2,3}', + 'xticklabels': '{ll-n-nc, s-ns, ll-s-ns}', + 'title': 'Notifications vs No Sleep' + }, + 'strategies': { + 'ymax': '250', + 'xtick': '{1,2,3}', + 'xticklabels': '{vanilla, pipe, \\waitfd{}}', + 'title': 'Sleep Strategies' + }, +} + + +def generate_plot_specifics() -> str: + """Generate plot specifics for the plot passed via the environment""" + plot = os.environ['BOXPLOT'] + if not plot: + return '' + + if plot not in PLOT_SPECIFICS: + print(f'ERROR: specified plot "{plot}" unknown', file=sys.stderr) + sys.exit(1) + + tikz_lines = [] + for key, value in PLOT_SPECIFICS[plot].items(): + tikz_lines.append(f'{key}={value}') + + return ',\n'.join(tikz_lines) + def parse_data(stream) -> T.Optional[Data]: """Convert yamls string to dict""" @@ -15,22 +82,27 @@ def parse_data(stream) -> T.Optional[Data]: TIKZ_TEMPLATE = \ """\\documentclass[]{standalone} -\\usepackage{pgfplots} -\\pgfplotsset{compat=1.17} -\\usepgfplotslibrary{statistics} +\\input{common.tex} \\begin{document} \\begin{tikzpicture} \\begin{axis}[ + mark=x, boxplot/draw direction=y, legend columns=2, area legend, - ylabel="latency [us]", + xmin=0, + xtick pos=bottom, + ytick pos=left, + xminorticks=false, + yminorticks=false, + ymajorgrids=true, legend style={ draw=none, fill=none, at={(0.5,-0.1)}, anchor=north }, + $PLOT_SPECIFICS$ ] $PLOTS$ \\end{axis} @@ -40,6 +112,7 @@ $PLOTS$ PLOT_TEMPLATE = \ """\\addplot+[ + mark=x, boxplot prepared={{ lower whisker={lower_whisker}, lower quartile={lower_quartile}, @@ -49,13 +122,15 @@ PLOT_TEMPLATE = \ upper whisker={upper_whisker}, }}, ] coordinates{{{outlier_cords}}}; -\\addlegendentry{{{variant}}} +%\\addlegendentry{{{variant}}} """ def generate_boxplot(data: Data) -> str: """generate a tikzboxplot""" + plots = '' + for variant, stats in data.items(): outlier_cords = '' for outlier in stats['outliers']: @@ -64,7 +139,11 @@ def generate_boxplot(data: Data) -> str: outlier_cords=outlier_cords, **stats) - return TIKZ_TEMPLATE.replace('$PLOTS$', plots) + tikz = TIKZ_TEMPLATE.replace('$PLOTS$', plots) + + plot_specifics = generate_plot_specifics() + tikz = tikz.replace('$PLOT_SPECIFICS$', plot_specifics) + return tikz def main(): diff --git a/muhq-ma-plots.sh b/muhq-ma-plots.sh index 64dc6e0..b51a7c5 100755 --- a/muhq-ma-plots.sh +++ b/muhq-ma-plots.sh @@ -6,6 +6,7 @@ SUM=./summarize.py PLOT=./gen_boxplots.py PLOT_DIR=plots/ +PLOT_PREFIX=iol RESULTS=$1 shift @@ -15,20 +16,28 @@ if [[ -z "${RESULTS}" ]]; then exit 1 fi -${SUM} --yaml -i emper-pipe emper-pipe-no-hint -- "${RESULTS}" | ${PLOT} > ${PLOT_DIR}/io-latency-hints.tex +${SUM} --yaml -i emper-pipe emper-pipe-no-hint -- "${RESULTS}" \ + | BOXPLOT="hints" ${PLOT} > ${PLOT_DIR}/${PLOT_PREFIX}-hints.tex ${SUM} --yaml -i emper-pipe emper-pipe-no-comp emper-io-stealing-pipe-no-comp -- "${RESULTS}" \ - | ${PLOT} > ${PLOT_DIR}/io-latency.tex + | BOXPLOT="latency" ${PLOT} > ${PLOT_DIR}/${PLOT_PREFIX}-latency.tex -${SUM} --yaml -i emper-pipe emper-waitfd -- "${RESULTS}" | ${PLOT} > ${PLOT_DIR}/pipe-vs-waitfd.tex +${SUM} --yaml -i emper-vanilla emper-no-sleep -- "${RESULTS}" \ + | BOXPLOT="contention" ${PLOT} > ${PLOT_DIR}/${PLOT_PREFIX}-contention.tex + +${SUM} --yaml -i emper-vanilla emper-pipe emper-waitfd -- "${RESULTS}" \ + | BOXPLOT="strategies" ${PLOT} > ${PLOT_DIR}/${PLOT_PREFIX}-strategies.tex ${SUM} --yaml -i emper-io-notification-waitfd-no-comp emper-io-notification-waitfd \ emper-io-stealing-waitfd-no-comp emper-io-stealing-waitfd -- "${RESULTS}" \ - | ${PLOT} > ${PLOT_DIR}/notification-stealing-completer.tex + | BOXPLOT="n-s-c" ${PLOT} > ${PLOT_DIR}/${PLOT_PREFIX}-notification-stealing-completer.tex ${SUM} --yaml -i emper-io-notification-lockless-waitfd-no-comp emper-io-notification-waitfd-no-comp \ emper-io-stealing-lockless-waitfd-no-comp emper-io-stealing-waitfd-no-comp -- "${RESULTS}" \ - | ${PLOT} > ${PLOT_DIR}/lockless-vs-locked.tex + | BOXPLOT="l-vs-ll" ${PLOT} > ${PLOT_DIR}/${PLOT_PREFIX}-lockless-vs-locked.tex + +${SUM} --yaml -i emper-io-notification-lockless-waitfd-no-comp \ + emper-stealing-no-sleep emper-stealing-lockless-no-sleep -- "${RESULTS}" \ + | BOXPLOT="n-vs-ns" ${PLOT} > ${PLOT_DIR}/${PLOT_PREFIX}-notification-vs-nosleep.tex + -${SUM} --yaml -i emper-io-notification-lockless-waitfd-no-comp emper-no-sleep -- "${RESULTS}" \ - | ${PLOT} > ${PLOT_DIR}/notification-vs-nosleep.tex diff --git a/plots/common.tex b/plots/common.tex new file mode 100644 index 0000000..07c23b1 --- /dev/null +++ b/plots/common.tex @@ -0,0 +1,7 @@ +\usepackage{pgfplots} +\pgfplotsset{compat=1.17} +\usepgfplotslibrary{statistics} + +\NewDocumentCommand \Waitfd{}{\texttt{Suspendfd}} +\NewDocumentCommand \waitfd{}{\texttt{suspendfd}} +\NewDocumentCommand \vertPhantom {}{\vphantom{gG}} -- GitLab