-
Notifications
You must be signed in to change notification settings - Fork 2
/
warmup.krun
233 lines (206 loc) · 7.99 KB
/
warmup.krun
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
import os
import sys
import platform
from krun.vm_defs import (PythonVMDef, LuaVMDef, JavaVMDef, GraalVMDef,
PHPVMDef, TruffleRubyVMDef, V8VMDef,
NativeCodeVMDef, find_internal_jvmci_java_home,
find_internal_jvmci_java_bin, PyPyVMDef)
from krun import EntryPoint
from krun.util import run_shell_cmd
def ghz(x):
return x * 1000 * 1000 * 1000
# we say a core was idle if APERF was less than 1/1000th a busy count (per second)
IDLE_DIVIDE = 1000
# Rough rate of APERF increment per second.
# On our machines, APERF happens to increment at the same rate as the base
# frequency.
BUSY_THRESHOLDS = {
"bencher5": ghz(3.6) / IDLE_DIVIDE,
"bencher7": ghz(3.5) / IDLE_DIVIDE,
# bencher6 not listed, as Krun doesn't support APERF on BSD
}
# Who to mail
MAIL_TO = []
HOSTNAME = platform.node().split(".")[0]
DIR = os.getcwd()
JKRUNTIME_DIR = os.path.join(DIR, "krun", "libkruntime", "")
if sys.platform.startswith("linux"):
JDK8_HOME = os.path.join(DIR, "work/openjdk/build/linux-x86_64-normal-server-release/images/j2sdk-image/")
elif sys.platform.startswith("openbsd"):
JDK8_HOME = os.path.join(DIR, "work/openjdk/build/bsd-x86_64-normal-server-release/images/j2sdk-image/")
else:
raise NotImplementedError("unknown platform")
JDK8_BIN = os.path.join(JDK8_HOME, "bin", "java")
if sys.platform.startswith("linux"):
GCC_ENV = {"LD_LIBRARY_PATH": os.path.join(DIR, "work/gcc-inst/lib64")}
elif sys.platform.startswith("openbsd"):
GCC_ENV = {"LD_LIBRARY_PATH": os.path.join(DIR, "work/gcc-inst/lib")}
else:
raise NotImplementedError("unknown platform")
HEAP_LIMIT = 2097152 # 2GiB
STACK_LIMIT = 8192 # 8 MiB
# Variant name -> EntryPoint
VARIANTS = {
"default-c": EntryPoint("bench.so", subdir="c"),
"default-java": EntryPoint("KrunEntry", subdir="java"),
"default-lua": EntryPoint("bench.lua", subdir="lua"),
"default-python": EntryPoint("bench.py", subdir="python"),
"default-php": EntryPoint("bench.php", subdir="php"),
"default-ruby": EntryPoint("bench.rb", subdir="ruby"),
"default-javascript": EntryPoint("bench.js", subdir="javascript"),
}
ITERATIONS_ALL_VMS = 2000
VMS = {
'C': {
'vm_def': NativeCodeVMDef(env=GCC_ENV),
'variants': ['default-c'],
'n_iterations': ITERATIONS_ALL_VMS,
},
'PyPy': {
'vm_def': PyPyVMDef('work/pypy/pypy/goal/pypy-c',
env=GCC_ENV),
'variants': ['default-python'],
'n_iterations': ITERATIONS_ALL_VMS,
},
'HotSpot': {
'vm_def': JavaVMDef(JDK8_BIN, env=GCC_ENV),
'variants': ['default-java'],
'n_iterations': ITERATIONS_ALL_VMS,
},
'LuaJIT': {
'vm_def': LuaVMDef('work/luajit/src/luajit', env=GCC_ENV),
'variants': ['default-lua'],
'n_iterations': ITERATIONS_ALL_VMS,
},
'V8': {
'vm_def': V8VMDef('work/v8/out/native/d8', env=GCC_ENV),
'variants': ['default-javascript'],
'n_iterations': ITERATIONS_ALL_VMS,
},
'CPython': {
'vm_def': PythonVMDef('work/cpython-inst/bin/python',
env=GCC_ENV),
'variants': ['default-python'],
'n_iterations': ITERATIONS_ALL_VMS,
}
}
if not sys.platform.startswith("openbsd"):
JVMCI_JAVA_HOME = find_internal_jvmci_java_home('work/graal-jvmci-8/')
# The following VMs do not run on OpenBSD.
VMS.update({
'Graal': {
'vm_def': GraalVMDef('work/graal', 'work/mx/mx',
java_home=JVMCI_JAVA_HOME, env=GCC_ENV),
'variants': ['default-java'],
'n_iterations': ITERATIONS_ALL_VMS,
},
'HHVM': {
'vm_def': PHPVMDef('work/hhvm/hphp/hhvm/php', env=GCC_ENV),
'variants': ['default-php'],
'n_iterations': ITERATIONS_ALL_VMS,
},
'TruffleRuby': {
'vm_def': TruffleRubyVMDef(truffleruby_dir='work/truffleruby',
graal_home='work/graal',
mx_dir='work/mx',
jvmci_home=JVMCI_JAVA_HOME,
env=GCC_ENV),
'variants': ['default-ruby'],
'n_iterations': ITERATIONS_ALL_VMS,
},
})
BENCHMARKS = {
'binarytrees': 25,
'richards': 500,
'spectralnorm': 3,
'nbody': 15,
'fasta': 100,
'fannkuch_redux': 200,
}
# list of "bench:vm:variant"
SKIP = [
# Uncomment to skip whole VMs
#
#"*:PyPy:*",
"*:CPython:*",
#"*:HotSpot:*",
#"*:Graal:*",
#"*:LuaJIT:*",
#"*:HHVM:*",
#"*:TruffleRuby:*",
#"*:V8:*",
#"*:C:*",
# Skipped due to being really slow.
"richards:HHVM:default-php",
"nbody:HHVM:default-php",
"fasta:TruffleRuby:default-ruby",
]
N_EXECUTIONS = 30 # Number of fresh processes.
if sys.platform.startswith("linux"):
AMPERF_RATIO_BOUNDS = 0.995, 1.005
AMPERF_BUSY_THRESHOLD = BUSY_THRESHOLDS[HOSTNAME]
if sys.platform.startswith("linux"):
# Assumes systemd is used for init.
PING_HOST = "bencher8.soft-dev.org"
PRE_EXECUTION_CMDS = [
# Stop network first. If an interface accepts a DHCP lease during one
# of the later commands below, it can cause the command to be
# "cancelled" by systemd. Bringing the network itself down can fail in
# the same way, so keep trying (with sleeps between).
"while true; do sudo systemctl stop networking; sleep 5; ping -q -c 10 %s || break; done" % PING_HOST,
"sudo systemctl stop cron",
"sudo systemctl stop atd",
"sudo systemctl stop postfix",
"sudo systemctl stop systemd-tmpfiles-clean.timer",
"sudo systemctl stop ssh",
]
POST_EXECUTION_CMDS = [
# The network doesn't always come up properly on debian. We keep trying
# until we can ping a host on the network.
"while true; do ping -c 3 -q %s && break; sudo systemctl stop networking; sleep 5; sudo systemctl start networking; done" % PING_HOST,
"sudo systemctl start ssh || true",
"sudo systemctl start cron || true",
"sudo systemctl start atd || true",
"sudo systemctl start postfix || true",
"sudo systemctl start systemd-tmpfiles-clean.timer || true",
]
elif sys.platform.startswith("openbsd"):
PRE_EXECUTION_CMDS = [
"sudo /etc/rc.d/ntpd stop",
"sudo /etc/rc.d/cron stop",
"sudo /etc/rc.d/smtpd stop",
"sudo /etc/rc.d/pflogd stop",
"sudo /etc/rc.d/sshd stop",
"for intf in `ifconfig | grep -e '^[a-z]' | cut -f 1 -d ':' | grep -v '^lo0$'`; do sudo ifconfig $intf down; done",
]
POST_EXECUTION_CMDS = [
"sudo sh /etc/netstart",
"sudo /etc/rc.d/sshd start || true",
"sudo /etc/rc.d/ntpd start || true",
"sudo /etc/rc.d/cron start || true",
"sudo /etc/rc.d/smtpd start || true",
"sudo /etc/rc.d/pflogd start || true",
]
else:
assert False
# Copy off results after each execution -- soft-dev specific!
#
# This assumes a no-password SSH key named 'id_rsa' is present in this
# directory, and that the corresponding public key is installed on the correct
# user on the remote machine.
#
# We allow failure, otherwise Krun will halt the experiment if (e.g.) the
# SSH server hostname is temporarily unavailable.
REMOTE_LOGIN = "[email protected]"
REMOTE_DIR = "research/krun_results/"
COOKIE_PATH = os.path.join(REMOTE_DIR, HOSTNAME + ".stop")
SSH_BATCH = "ssh -o 'BatchMode yes' -i id_rsa"
SCP_CMD = ("tar czf - ${KRUN_RESULTS_FILE} ${KRUN_LOG_FILE} ${KRUN_MANIFEST_FILE} | "
"%s %s 'cat > %s/%s.tgz'" %
(SSH_BATCH, REMOTE_LOGIN, REMOTE_DIR, HOSTNAME))
POST_EXECUTION_CMDS.append(
"%s || ( sleep 2; %s ) || true " % (SCP_CMD, SCP_CMD))
# Crash if the "stop cookie" exists on the remote host.
# Allows us to stop machines with no remote management.
POST_EXECUTION_CMDS.append("{0} {1} ls {2} 2> /dev/null | grep {2}; exit $((! $?))".format(
SSH_BATCH, REMOTE_LOGIN, COOKIE_PATH))