-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathbenchmark.sh
executable file
·151 lines (130 loc) · 4.39 KB
/
benchmark.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#!/bin/bash
# verbose output
set -x
source ../common/set-cpus.sh
TOOLSDIR=$(pwd)/../../tools
IMAGES=$(pwd)/images/
RESULTS=$(pwd)/results/
FIRECRACKER_PATH=$(pwd)/.firecracker
VMMSOCKET=$(pwd)/.firecracker.socket
mkdir -p $RESULTS
function cleanup {
# kill all children (evil)
pkill -P $$
}
trap "cleanup" EXIT
function firecracker_cleanup {
sudo pkill -9 firecracker-x86
sudo pkill -9 firecracker
sudo pkill -9 firectl
sudo rm -f $VMMSOCKET
}
function runlupine {
cp ${IMAGES}/lupine-portwrite.ext2 /tmp/lupine-portwrite.ext2.disp
cp ${IMAGES}/${1}.img /tmp/${1}.img
touch .out
{
sleep 3
firecracker_cleanup
rm /tmp/lupine-portwrite.ext2.disp /tmp/${1}.img
} &
taskset -c ${CPU1} firectl --firecracker-binary=$(pwd)/.firecracker \
--kernel /tmp/${1}.img \
--kernel-opts='ro panic=-1 pci=off reboot=k tsc=reliable quiet 8250.nr_uarts=0 ipv6.disable=1 init=/measure-boot-fc' \
--root-drive=/tmp/lupine-portwrite.ext2.disp \
--firecracker-log=.out > /dev/null 2> /dev/null
# get CPU ms
cat .out | grep Guest-boot-time | rev | awk -e '$0 {print $3}' | \
rev | awk -e '$0 {print int(1000000*($1))}'
rm .out
wait
}
# return boot time for $vm
function runvm {
vm=$1
if [ "$vm" = "alpine-vm" ]; then
cp ${IMAGES}/alpine.raw /tmp/alpine.raw.disposible
{
sleep 8
firecracker_cleanup
rm /tmp/alpine.raw.disposible
} &
taskset -c ${CPU1} firectl --kernel=${IMAGES}/hello-vmlinux.bin \
--root-drive=/tmp/alpine.raw.disposible \
--firecracker-binary=$(pwd)/.firecracker \
--firecracker-log=.out > /dev/null 2> /dev/null
cat .out | grep Guest-boot-time | rev | awk -e '$0 {print $3}' | \
rev | awk -e '$0 {print int(1000000*($1))}'
rm .out
wait
elif [ "$vm" = "lupine" ]; then
runlupine $vm
elif [ "$vm" = "lupine-nokml" ]; then
runlupine $vm
elif [ "$vm" = "hermitux" ]; then
docker pull hlefeuvre/hermitux-boottime > /dev/null 2> /dev/null
docker run --privileged --cpuset-cpus="${CPU1}-${CPU3}" \
hlefeuvre/hermitux-boottime | \
awk -e '$0 ~ /([0-9]+)ns/ {print $4}' | \
cut -c 4- | rev | cut -c 3- | rev
elif [ "$vm" = "hermitux-light" ]; then
docker pull hlefeuvre/hermitux-light-boottime > /dev/null 2> /dev/null
docker run --privileged --cpuset-cpus="${CPU1}-${CPU3}" \
hlefeuvre/hermitux-light-boottime | \
awk -e '$0 ~ /([0-9]+)ns/ {print $4}' | \
cut -c 4- | rev | cut -c 3- | rev
elif [ "$vm" = "osv-rofs" ]; then
CONTAINER=osv
docker pull hlefeuvre/osv > /dev/null 2> /dev/null
docker run --privileged --name=$CONTAINER \
--cpuset-cpus="${CPU1}-${CPU3}" \
-dt hlefeuvre/osv > /dev/null 2> /dev/null
docker exec -it $CONTAINER ./scripts/firecracker.py -c 1 -m 128M | \
awk -e '$0 ~ /Booted/ {print int(1000000*($4))}'
docker container stop $CONTAINER > /dev/null 2> /dev/null
docker rm -f $CONTAINER > /dev/null 2> /dev/null
firecracker_cleanup
elif [ "$vm" = "mirage-solo5" ]; then
taskset -c ${CPU1} $TOOLSDIR/solo5-hvt-noop-timer ${IMAGES}/mirage-noop.hvt \
2>&1 >/dev/null | grep "guest" | awk -F "[()]" '{print $2}'
elif [ "$vm" = "rump" ]; then
CONTAINER=rump
docker pull hlefeuvre/rump-solo5-boottime > /dev/null 2> /dev/null
docker run --privileged -it --cpuset-cpus="${CPU1}-${CPU3}" \
hlefeuvre/rump-solo5-boottime | \
awk -e '$0 ~ /guest startup/ {print $4}' | rev | cut -c 3- | rev |
awk '{print int(1000*($0))}'
elif [ "$vm" = "docker-min" ]; then
{
docker events > .out
} &
child=$!
docker pull hello-world > /dev/null 2> /dev/null
docker run -m 30MB --privileged \
--cpuset-cpus="${CPU1}-${CPU3}" \
-it hello-world > /dev/null 2> /dev/null
kill $child > /dev/null 2> /dev/null
LC_NUMERIC="C" grep -P "container (start|die)" .out | tr :+ ' ' | \
awk '{if(NR>1){print int(1000000000*($3-last))} last=$3}'
rm .out
fi
}
# return boot time for $vm, repeated $num times
function benchit {
num=$1
vm=$2
for i in $( seq 1 ${num} ); do
runvm $vm >> rawdata/${vm}.txt
sleep 2
done
}
mkdir -p rawdata results
for vm in "alpine-vm" "lupine" "lupine-nokml" "hermitux" \
"hermitux-light" "osv-rofs" "rump" "docker-min" "mirage-solo5"
do
benchit 30 ${vm}
echo "boottime_ms" > results/${vm}.csv
cat rawdata/${vm}.txt | \
awk '{ total += $1; count++ } END { OFMT="%f"; print total/(count*1000000) }' \
>> results/${vm}.csv
done