|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "markdown", |
| 5 | + "metadata": {}, |
| 6 | + "source": [ |
| 7 | + "# License" |
| 8 | + ] |
| 9 | + }, |
| 10 | + { |
| 11 | + "cell_type": "markdown", |
| 12 | + "metadata": {}, |
| 13 | + "source": [ |
| 14 | + "Copyright (c) 2018, ARM Limited. All rights reserved.\n", |
| 15 | + "\n", |
| 16 | + "SPDX-License-Identifier: BSD-3-Clause\n", |
| 17 | + "\n", |
| 18 | + "Redistribution and use in source and binary forms, with or without\n", |
| 19 | + "modification, are permitted provided that the following conditions are met:\n", |
| 20 | + "\n", |
| 21 | + "Redistributions of source code must retain the above copyright notice, this\n", |
| 22 | + "list of conditions and the following disclaimer.\n", |
| 23 | + "\n", |
| 24 | + "Redistributions in binary form must reproduce the above copyright notice, this\n", |
| 25 | + "list of conditions and the following disclaimer in the documentation and/or\n", |
| 26 | + "other materials provided with the distribution.\n", |
| 27 | + "\n", |
| 28 | + "Neither the name of ARM Limited nor the names of its contributors may be used\n", |
| 29 | + "to endorse or promote products derived from this software without specific\n", |
| 30 | + "prior written permission.\n", |
| 31 | + "\n", |
| 32 | + "THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n", |
| 33 | + "AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n", |
| 34 | + "IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n", |
| 35 | + "DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE\n", |
| 36 | + "FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n", |
| 37 | + "DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\n", |
| 38 | + "SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\n", |
| 39 | + "CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR\n", |
| 40 | + "TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n", |
| 41 | + "OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." |
| 42 | + ] |
| 43 | + }, |
| 44 | + { |
| 45 | + "cell_type": "markdown", |
| 46 | + "metadata": {}, |
| 47 | + "source": [ |
| 48 | + "# Prerequisite Libraries" |
| 49 | + ] |
| 50 | + }, |
| 51 | + { |
| 52 | + "cell_type": "markdown", |
| 53 | + "metadata": {}, |
| 54 | + "source": [ |
| 55 | + "- ## python3\n", |
| 56 | + "`apt install python3 python3-pip`\n", |
| 57 | + "- ## jupyter-notebook\n", |
| 58 | + "`apt install jupyter-notebook`\n", |
| 59 | + "- ## matplotlib seaborn pandas numpy\n", |
| 60 | + "`pip3 install matplotlib seaborn pandas numpy`" |
| 61 | + ] |
| 62 | + }, |
| 63 | + { |
| 64 | + "cell_type": "markdown", |
| 65 | + "metadata": {}, |
| 66 | + "source": [ |
| 67 | + "# Matplotlib and Seaborn Settings" |
| 68 | + ] |
| 69 | + }, |
| 70 | + { |
| 71 | + "cell_type": "code", |
| 72 | + "execution_count": null, |
| 73 | + "metadata": { |
| 74 | + "collapsed": false |
| 75 | + }, |
| 76 | + "outputs": [], |
| 77 | + "source": [ |
| 78 | + "%matplotlib inline\n", |
| 79 | + "import matplotlib\n", |
| 80 | + "import matplotlib.pyplot as plt\n", |
| 81 | + "import seaborn as sns\n", |
| 82 | + "import pandas as pd\n", |
| 83 | + "import numpy as np\n", |
| 84 | + "import warnings\n", |
| 85 | + "warnings.filterwarnings('ignore')\n", |
| 86 | + "sns.set()\n", |
| 87 | + "\n", |
| 88 | + "# default 12 colors and markers\n", |
| 89 | + "default_palette = [\n", |
| 90 | + " '#765f97', #Purple\n", |
| 91 | + " '#1b9e77', #Dark Green\n", |
| 92 | + " '#8c5c20', #Brown\n", |
| 93 | + " '#0038bd', #Blue\n", |
| 94 | + " '#cf364a', #Red\n", |
| 95 | + " '#343434', #Jet Black\n", |
| 96 | + " '#878681', #Titanium Gray\n", |
| 97 | + " '#f561dd', #Magenta\n", |
| 98 | + " '#a6cee3', #Calico Blue\n", |
| 99 | + " '#dea0dd', #Plum\n", |
| 100 | + " '#7fc97f', #Grass Green\n", |
| 101 | + " '#fdc086', #Pale Yellow\n", |
| 102 | + " ]\n", |
| 103 | + "\n", |
| 104 | + "default_markers=['^', '*', 'd', 'x', 'D', 'o', 'v', 's', 'p', '>', '<', '.']\n", |
| 105 | + "default_marker_size = 100\n", |
| 106 | + "\n", |
| 107 | + "# seaborn settings\n", |
| 108 | + "sns.set(context=\"notebook\", style=\"darkgrid\", font_scale=2, rc={\"lines.linewidth\": 3, \"xtick.major.size\": 4, \"ytick.major.size\": 4})\n", |
| 109 | + "sns.set_palette(default_palette)\n", |
| 110 | + "sns.palplot(sns.color_palette())" |
| 111 | + ] |
| 112 | + }, |
| 113 | + { |
| 114 | + "cell_type": "markdown", |
| 115 | + "metadata": {}, |
| 116 | + "source": [ |
| 117 | + "# Lockhammer Common Settings" |
| 118 | + ] |
| 119 | + }, |
| 120 | + { |
| 121 | + "cell_type": "code", |
| 122 | + "execution_count": null, |
| 123 | + "metadata": { |
| 124 | + "collapsed": true |
| 125 | + }, |
| 126 | + "outputs": [], |
| 127 | + "source": [ |
| 128 | + "# common variables\n", |
| 129 | + "lock_workloads = [\"cas_event_mutex\", \"cas_lockref\", \"cas_rw_lock\", \"incdec_refcount\", \"osq_lock\", \"queued_spinlock\", \"ticket_spinlock\", \"jvm_objectmonitor\", \"swap_mutex\", \"tbb_spin_rw_mutex\", \"event_mutex\", \"empty\"]\n", |
| 130 | + "lock_hosts = [\"x86-1\", \"x86-2\", \"x86-3\", \"x86-4\"]\n", |
| 131 | + "lock_parameters = [[\"-c\", \"200ns\", \"-p\", \"1000ns\"]]\n", |
| 132 | + "exectx_count_max = 88\n", |
| 133 | + "exectx_count_gap = 4\n", |
| 134 | + "lh_csv_result_header = [\"num_threads\", \"avg_exectx\", \"scheduled_time_per_access\", \"real_time_per_access\", \"access_rate\", \"avg_lock_depth\",\n", |
| 135 | + " \"date\", \"fqdn\", \"exec\", \"t\", \"tv\", \"a\", \"av\", \"c\", \"cv\", \"p\", \"pv\", \"o\", \"ov\"]\n", |
| 136 | + "\n", |
| 137 | + "param_name = \"contended_system_latency (ns)\"\n", |
| 138 | + "lock_yaxis_name = param_name\n", |
| 139 | + "\n", |
| 140 | + "# lockhammer-all.csv.xz is a xz-compressed aggregated file of different machines' raw csv result\n", |
| 141 | + "raw_csv_filename = \"lockhammer-all.csv.xz\"\n", |
| 142 | + "raw_df = pd.read_csv(raw_csv_filename, sep=', ', header=None, names=lh_csv_result_header, engine='python')\n", |
| 143 | + "\n", |
| 144 | + "# common functions\n", |
| 145 | + "def plot_lines_only(dataf):\n", |
| 146 | + " # each test repeat 9 times, but we only plot the median latency (access_rate)\n", |
| 147 | + " median_list = []\n", |
| 148 | + " for hst, grp0 in dataf.groupby(\"host\"):\n", |
| 149 | + " for nth, grp1 in grp0.groupby(\"num_threads\"):\n", |
| 150 | + " median_list.append({\"host\": hst, \"num_threads\": nth, param_name: grp1.median()[param_name]})\n", |
| 151 | + " median_df = pd.DataFrame(median_list)\n", |
| 152 | + " \n", |
| 153 | + " from matplotlib.colors import ListedColormap\n", |
| 154 | + " cmap = ListedColormap(sns.color_palette(default_palette).as_hex())\n", |
| 155 | + " for i, (hst, grp2) in enumerate(median_df.groupby(\"host\")):\n", |
| 156 | + " plt.plot(\"num_threads\", param_name, data=grp2, color=cmap(i))" |
| 157 | + ] |
| 158 | + }, |
| 159 | + { |
| 160 | + "cell_type": "markdown", |
| 161 | + "metadata": {}, |
| 162 | + "source": [ |
| 163 | + "# Lockhammer all workloads, raw contended system latency, 2018.11.06." |
| 164 | + ] |
| 165 | + }, |
| 166 | + { |
| 167 | + "cell_type": "code", |
| 168 | + "execution_count": null, |
| 169 | + "metadata": { |
| 170 | + "collapsed": false, |
| 171 | + "scrolled": false |
| 172 | + }, |
| 173 | + "outputs": [], |
| 174 | + "source": [ |
| 175 | + "# use lmplot (not catplot) to plot raw system latencies\n", |
| 176 | + "for param in lock_parameters:\n", |
| 177 | + " for workload in lock_workloads:\n", |
| 178 | + " tidy_df = pd.DataFrame()\n", |
| 179 | + " for sut in sorted(lock_hosts):\n", |
| 180 | + " host_df = raw_df.loc[(raw_df['fqdn'].str.startswith(sut) & raw_df['exec'].str.endswith(workload))]\n", |
| 181 | + " test_df = host_df.loc[(host_df['cv'] == param[1]) & (host_df['pv'] == param[3])]\n", |
| 182 | + " copy_df = test_df.copy()\n", |
| 183 | + " copy_df['host'] = sut\n", |
| 184 | + " all_df = pd.melt(copy_df, id_vars=['host', 'num_threads'], value_vars=['access_rate'], value_name=param_name)\n", |
| 185 | + " tidy_df = pd.concat([tidy_df, all_df])\n", |
| 186 | + " \n", |
| 187 | + " # because lmplot doesn't plot lines, we have to use plot_lines_only to plot them\n", |
| 188 | + " sns.lmplot(x=\"num_threads\", y=param_name, hue=\"host\", data=tidy_df, x_estimator=np.median, x_ci=50,\n", |
| 189 | + " height=10, aspect=2, fit_reg=False, markers=default_markers[:len(lock_hosts)], scatter_kws={\"s\": default_marker_size})\n", |
| 190 | + " \n", |
| 191 | + " # plot lines which connect lmplot dots\n", |
| 192 | + " plot_lines_only(tidy_df)\n", |
| 193 | + " \n", |
| 194 | + " # change title / axis and save the figure\n", |
| 195 | + " plt.title(\"lockhammer workload: {}, critical_time: {}, parallel_time: {}\".format(workload, param[1], param[3]))\n", |
| 196 | + " plt.xlim(0, exectx_count_max)\n", |
| 197 | + " plt.xticks(np.arange(0, exectx_count_max+1, exectx_count_gap))\n", |
| 198 | + " plt.savefig(\"github_lockhammer_all_common_20181106_{}_{}_{}.png\".format(workload, param[1], param[3]))" |
| 199 | + ] |
| 200 | + }, |
| 201 | + { |
| 202 | + "cell_type": "code", |
| 203 | + "execution_count": null, |
| 204 | + "metadata": { |
| 205 | + "collapsed": true |
| 206 | + }, |
| 207 | + "outputs": [], |
| 208 | + "source": [] |
| 209 | + } |
| 210 | + ], |
| 211 | + "metadata": { |
| 212 | + "kernelspec": { |
| 213 | + "display_name": "Python 3", |
| 214 | + "language": "python", |
| 215 | + "name": "python3" |
| 216 | + }, |
| 217 | + "language_info": { |
| 218 | + "codemirror_mode": { |
| 219 | + "name": "ipython", |
| 220 | + "version": 3 |
| 221 | + }, |
| 222 | + "file_extension": ".py", |
| 223 | + "mimetype": "text/x-python", |
| 224 | + "name": "python", |
| 225 | + "nbconvert_exporter": "python", |
| 226 | + "pygments_lexer": "ipython3", |
| 227 | + "version": "3.6.3" |
| 228 | + } |
| 229 | + }, |
| 230 | + "nbformat": 4, |
| 231 | + "nbformat_minor": 2 |
| 232 | +} |
0 commit comments