-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Plumb in extra instrumentation mode iterations runners flags. #367
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,12 +37,13 @@ | |
|
||
""" | ||
Iterations runner for Python VMs. | ||
Derived from iterations_runner.php. | ||
|
||
Executes a benchmark many times within a single process. | ||
|
||
In Kalibera terms, this script represents one executions level run. | ||
""" | ||
usage: iterations_runner.py <benchmark> <# of iterations> <benchmark param> | ||
<debug flag> [instrumentation dir] [key] [key pexec index] | ||
|
||
Arguments in [] are for instrumentation mode only.""" | ||
|
||
import cffi, sys, imp, os | ||
|
||
|
@@ -70,20 +71,25 @@ | |
krun_get_aperf = libkruntime.krun_get_aperf | ||
krun_get_mperf = libkruntime.krun_get_mperf | ||
|
||
def usage(): | ||
print(__doc__) | ||
sys.exit(1) | ||
|
||
# main | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this comment necessary? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. probably not :P |
||
if __name__ == "__main__": | ||
if len(sys.argv) != 6: | ||
sys.stderr.write("usage: iterations_runner.py <benchmark> " | ||
"<# of iterations> <benchmark param> <debug flag> " | ||
"<instrument flag>\n") | ||
sys.exit(1) | ||
num_args = len(sys.argv) | ||
if num_args < 5: | ||
usage() | ||
|
||
benchmark, iters, param, debug = sys.argv[1:5] | ||
iters, param, debug = int(iters), int(param), int(debug) == 1 | ||
instrument = num_args >= 6 | ||
|
||
benchmark, iters, param, debug, instrument = sys.argv[1:] | ||
iters, param, debug, instrument = \ | ||
int(iters), int(param), int(debug) == 1, int(instrument) == 1 | ||
if instrument and num_args != 8: | ||
usage() | ||
|
||
if instrument: | ||
import pypyjit # instrumentation not supported on CPython yet anyway | ||
import pypyjit # instrumentation not supported on CPython yet. | ||
|
||
assert benchmark.endswith(".py") | ||
bench_mod_name = os.path.basename(benchmark[:-3]) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -309,16 +309,57 @@ def _write_new_manifest(self, config): | |
for item in manifest: | ||
fh.write("%s\n" % item) | ||
|
||
def next_exec_key_index(self): | ||
"""Returns the sequential process execution index into the ordered list | ||
of all process executions sharing the same 'bench:vm:variant' key. | ||
|
||
Although this could have been done at `_parse()` time, it would require | ||
a (variable sized) `dict` since we don't know which key we will be | ||
counting for until we find the first outstanding (O) record. | ||
|
||
Instead, this method does a pass over the manifest searching for | ||
records whose key is `self.next_exec_key`. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like this very clear explanation! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks. It took a while to get the wording right on this one! |
||
|
||
This function assumes that there is at least one outstanding job (O | ||
line) in the manifest. If there is not, it will raise `FatalKrunError`. | ||
""" | ||
|
||
fh = self._open() | ||
lines = iter(fh) | ||
count = 0 | ||
|
||
# Skip header | ||
for line in lines: | ||
strip_line = line.strip() | ||
if strip_line == "keys": | ||
break | ||
else: | ||
util.fatal("Manifest is missing a body") | ||
|
||
# Now count the number of matching keys until the first 'O' | ||
# (outstanding) record. | ||
for line in lines: | ||
flag, key = line.strip().split() | ||
if key == self.next_exec_key: | ||
if flag == "O": | ||
break | ||
count += 1 | ||
else: | ||
util.fatal("Manifest ended unexpectedly") | ||
|
||
return count | ||
|
||
|
||
class ExecutionJob(object): | ||
"""Represents a single executions level benchmark run""" | ||
|
||
def __init__(self, sched, vm_name, vm_info, benchmark, variant, parameter): | ||
def __init__(self, sched, vm_name, vm_info, benchmark, variant, parameter, key_pexec_idx): | ||
self.sched = sched | ||
self.vm_name, self.vm_info = vm_name, vm_info | ||
self.benchmark = benchmark | ||
self.variant = variant | ||
self.parameter = parameter | ||
self.key_pexec_idx = key_pexec_idx | ||
|
||
# Used in results JSON and ETA dict | ||
self.key = "%s:%s:%s" % (self.benchmark, self.vm_name, self.variant) | ||
|
@@ -363,9 +404,10 @@ def run(self, mailer, dry_run=False): | |
stack_limit_kb = self.sched.config.STACK_LIMIT | ||
in_proc_iters = self.vm_info["n_iterations"] | ||
|
||
stdout, stderr, rc, envlog_filename = vm_def.run_exec( | ||
entry_point, self.benchmark, in_proc_iters, | ||
self.parameter, heap_limit_kb, stack_limit_kb) | ||
stdout, stderr, rc, envlog_filename = \ | ||
vm_def.run_exec(entry_point, in_proc_iters, self.parameter, | ||
heap_limit_kb, stack_limit_kb, self.key, | ||
self.key_pexec_idx) | ||
|
||
if not dry_run: | ||
try: | ||
|
@@ -497,8 +539,9 @@ def run(self): | |
self.platform.wait_for_temperature_sensors() | ||
|
||
bench, vm, variant = self.manifest.next_exec_key.split(":") | ||
key_pexec_idx = self.manifest.next_exec_key_index() | ||
job = ExecutionJob(self, vm, self.config.VMS[vm], bench, variant, | ||
self.config.BENCHMARKS[bench]) | ||
self.config.BENCHMARKS[bench], key_pexec_idx) | ||
|
||
# Default to error state. This is the value the finally block will see | ||
# if an exception is raised inside the try block, otherwise it is | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason behind not initialising
krun_core
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can do, although it will be initialised before its first use in the loop header:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, it just seems weird to be the odd one out on that line.