|
| 1 | +# MIT License |
| 2 | +# |
| 3 | +# Copyright (c) 2020 Dmitrii Ustiugov, Plamen Petrov and EASE lab |
| 4 | +# |
| 5 | +# Permission is hereby granted, free of charge, to any person obtaining a copy |
| 6 | +# of this software and associated documentation files (the "Software"), to deal |
| 7 | +# in the Software without restriction, including without limitation the rights |
| 8 | +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 9 | +# copies of the Software, and to permit persons to whom the Software is |
| 10 | +# furnished to do so, subject to the following conditions: |
| 11 | +# |
| 12 | +# The above copyright notice and this permission notice shall be included in all |
| 13 | +# copies or substantial portions of the Software. |
| 14 | +# |
| 15 | +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 16 | +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 17 | +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 18 | +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 19 | +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 20 | +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 21 | +# SOFTWARE. |
| 22 | + |
| 23 | +#!/bin/bash |
| 24 | + |
| 25 | +set -e |
| 26 | + |
| 27 | +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" |
| 28 | + |
| 29 | +ROOT="$( cd $DIR && cd .. && pwd)" |
| 30 | + |
| 31 | +source /etc/profile |
| 32 | +GO_BIN=`which go` |
| 33 | + |
| 34 | +cd $ROOT |
| 35 | + |
| 36 | +############## Supplementary functions below ############## |
| 37 | +die () { |
| 38 | + echo >&2 "$@" |
| 39 | + exit 1 |
| 40 | +} |
| 41 | + |
| 42 | +################### Main body below ####################### |
| 43 | + |
| 44 | +[ "$#" -eq 1 ] || die "1 argument required, $# provided" |
| 45 | + |
| 46 | +mode=$1 |
| 47 | + |
| 48 | +if [[ ! $mode =~ ^(baseline|reap)$ ]]; then |
| 49 | + die "Wrong mode specified, the scripts supports only the following modes: baseline, reap" |
| 50 | +fi |
| 51 | + |
| 52 | +host_ip=`curl ifconfig.me` |
| 53 | + |
| 54 | +wlds=(helloworld chameleon pyaes image_rotate_s3 json_serdes_s3 lr_serving cnn_serving rnn_serving lr_training_s3 video_processing_s3) |
| 55 | + |
| 56 | +all_results_path=all_results |
| 57 | +results_path=$all_results_path/$mode |
| 58 | +rm -rf $results_path || echo Folder $results_path exists, removing the old one. |
| 59 | +mkdir -p $results_path |
| 60 | + |
| 61 | +for wld in "${wlds[@]}" |
| 62 | +do |
| 63 | + echo |
| 64 | + echo About to run $mode/$wld experiment in $mode mode |
| 65 | + |
| 66 | + if [[ "$mode" == "reap" ]]; then |
| 67 | + modeFlag=-upfTest |
| 68 | + fi |
| 69 | + |
| 70 | + ############ Clean up after previous experiment ######## |
| 71 | + echo Killing the containerd daemon and cleaning up. |
| 72 | + ./scripts/clean_fcctr.sh 1>clean.out 2>clean.err |
| 73 | + wld_dir=$results_path/$wld |
| 74 | + mkdir -p $wld_dir |
| 75 | + |
| 76 | + ######################################################## |
| 77 | + echo Starting containerd daemon |
| 78 | + sudo PATH=$PATH /usr/local/bin/firecracker-containerd \ |
| 79 | + --config /etc/firecracker-containerd/config.toml \ |
| 80 | + 1>$wld_dir/containerd.out 2>$wld_dir/containerd.err & |
| 81 | + |
| 82 | + echo Wait for containerd to start |
| 83 | + sleep 2 |
| 84 | + |
| 85 | + ######################################################## |
| 86 | + echo Running the actual benchmark... may take up to one minute. |
| 87 | + |
| 88 | + sudo $GO_BIN test -v -run TestBenchServe \ |
| 89 | + -args -iter 5 \ |
| 90 | + -snapshotsTest \ |
| 91 | + -benchDirTest $results_path/$wld \ |
| 92 | + -metricsTest \ |
| 93 | + -funcName $wld \ |
| 94 | + -minioAddress http://$host_ip:9000 \ |
| 95 | + $modeFlag 1>$wld_dir/test.out 2>$wld_dir/test.err |
| 96 | + |
| 97 | + sleep 1 |
| 98 | + |
| 99 | + ################# Process latency stats ################# |
| 100 | + addInstanceMetric=`cat $wld_dir/serve.csv | tail -n 1 | cut -d"," -f2` |
| 101 | + if [[ "$mode" == "baseline" ]]; then |
| 102 | + funcInvocationMetric=`cat $wld_dir/serve.csv | tail -n 1 | cut -d"," -f8` |
| 103 | + else |
| 104 | + funcInvocationMetric=`cat $wld_dir/serve.csv | tail -n 1 | cut -d"," -f10` |
| 105 | + fi |
| 106 | + |
| 107 | + totalMetric=$(( (addInstanceMetric + funcInvocationMetric)/1000 )) |
| 108 | + |
| 109 | + echo Average function invocation took $totalMetric milliseconds |
| 110 | + |
| 111 | + echo $wld,$mode,$totalMetric >> $all_results_path/results.csv |
| 112 | +done |
0 commit comments