aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fl.fischer@fau.de>2019-08-20 23:11:24 +0200
committerFlorian Fischer <florian.fl.fischer@fau.de>2019-08-20 23:11:24 +0200
commit64e9b6dca11884ffff502857ee6be4d1d76e2953 (patch)
tree417336fc2bbffa8fdb5aa9a106f220bf48395eb8
parent20b0702b6a7a072ab61862205218e628203d1234 (diff)
parent468865c5de6ce2365a4afb86aacc05d81c0329c4 (diff)
downloadallocbench-64e9b6dca11884ffff502857ee6be4d1d76e2953.tar.gz
allocbench-64e9b6dca11884ffff502857ee6be4d1d76e2953.zip
Merge branch 'lld'
-rw-r--r--.gitignore1
-rw-r--r--src/benchmark.py37
-rw-r--r--src/benchmarks/lld.py99
3 files changed, 125 insertions, 12 deletions
diff --git a/.gitignore b/.gitignore
index 94d1b41..b0cb851 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,6 +2,7 @@ build/*
results/*
allocators/*.so
dj_workloads/*
+lld-speed-test*
*.png
*__pycache__*
.gdb_history
diff --git a/src/benchmark.py b/src/benchmark.py
index c2c0920..e8caa9d 100644
--- a/src/benchmark.py
+++ b/src/benchmark.py
@@ -173,7 +173,7 @@ class Benchmark (object):
self.calc_desc_statistics()
def prepare(self):
- os.environ["PATH"] += os.pathsep + "build/benchmarks/" + self.name
+ os.environ["PATH"] += f"{os.pathsep}{src.globalvars.builddir}/benchmarks/{self.name}"
for r in self.requirements:
exe = src.util.find_cmd(r)
@@ -243,6 +243,8 @@ class Benchmark (object):
ret = server.poll()
if ret is not None:
+ print_debug("Stdout:", server.stdout)
+ print_debug("Stderr:", server.stderr)
raise Exception("Starting Server failed with exit code " + str(ret))
# Register termination of the server
atexit.register(Benchmark.terminate_subprocess, popen=server)
@@ -290,7 +292,7 @@ class Benchmark (object):
env = dict(os.environ)
env["LD_PRELOAD"] = env.get("LD_PRELOAD", "")
- env["LD_PRELOAD"] += " " + "build/print_status_on_exit.so"
+ env["LD_PRELOAD"] += " " + f"{src.globalvars.builddir}/print_status_on_exit.so"
env["LD_PRELOAD"] += " " + alloc["LD_PRELOAD"]
if "LD_LIBRARY_PATH" in alloc:
@@ -336,6 +338,12 @@ class Benchmark (object):
argv.extend(cmd_argv)
+ cwd = os.getcwd()
+ if hasattr(self, "run_dir"):
+ run_dir = self.run_dir.format(**substitutions)
+ os.chdir(run_dir)
+ print_debug("\nChange cwd to:", run_dir)
+
print_debug("\nCmd:", argv)
res = subprocess.run(argv, stderr=subprocess.PIPE,
stdout=subprocess.PIPE,
@@ -355,15 +363,16 @@ class Benchmark (object):
# parse and store results
else:
if self.server_cmds == []:
- # Read VmHWM from status file. If our benchmark
- # didn't fork the first occurance of VmHWM is from
- # our benchmark
- with open("status", "r") as f:
- for l in f.readlines():
- if l.startswith("VmHWM:"):
- result["VmHWM"] = l.split()[1]
- break
- os.remove("status")
+ if os.path.isfile("status"):
+ # Read VmHWM from status file. If our benchmark
+ # didn't fork the first occurance of VmHWM is from
+ # our benchmark
+ with open("status", "r") as f:
+ for l in f.readlines():
+ if l.startswith("VmHWM:"):
+ result["VmHWM"] = l.split()[1]
+ break
+ os.remove("status")
# TODO: get VmHWM from servers
else:
result["server_status"] = []
@@ -396,6 +405,9 @@ class Benchmark (object):
self.results[alloc_name][perm] = []
self.results[alloc_name][perm].append(result)
+ if os.getcwd() != cwd:
+ os.chdir(cwd)
+
self.shutdown_servers()
if hasattr(self, "postallocator_hook"):
@@ -405,7 +417,8 @@ class Benchmark (object):
print()
# reset PATH
- os.environ["PATH"] = os.environ["PATH"].replace(":build/" + self.name, "")
+ os.environ["PATH"] = os.environ["PATH"].replace(f"{os.pathsep}{src.globalvars.builddir}/benchmarks/{self.name}", "")
+
# expand invalid results
if valid_result != {}:
diff --git a/src/benchmarks/lld.py b/src/benchmarks/lld.py
new file mode 100644
index 0000000..1a7b69e
--- /dev/null
+++ b/src/benchmarks/lld.py
@@ -0,0 +1,99 @@
+import matplotlib.pyplot as plt
+import numpy as np
+import os
+from urllib.request import urlretrieve
+import subprocess
+import sys
+
+from src.benchmark import Benchmark
+from src.util import print_status
+
+
+class BenchmarkLld(Benchmark):
+ def __init__(self):
+ self.name = "lld"
+ self.descrition = """This benchmark runs the lld benchmarks provided
+ by the llvm project."""
+
+ self.run_dir = "lld-speed-test/{test}"
+ # TODO: don't hardcode ld.lld location
+ self.cmd = "/usr/bin/ld.lld @response.txt"
+
+ self.args = {"test": ["chrome", "clang-fsds", "gold", "linux-kernel",
+ "llvm-as-fsds", "scylla", "clang", "clang-gdb-index",
+ "gold-fsds", "llvm-as", "mozilla"]}
+
+ self.requirements = ["ld.lld"]
+ super().__init__()
+
+ def prepare(self):
+ super().prepare()
+
+ def reporthook(blocknum, blocksize, totalsize):
+ readsofar = blocknum * blocksize
+ if totalsize > 0:
+ percent = readsofar * 1e2 / totalsize
+ s = "\r%5.1f%% %*d / %d" % (
+ percent, len(str(totalsize)), readsofar, totalsize)
+ sys.stderr.write(s)
+ else: # total size is unknown
+ sys.stderr.write("\rdownloaded %d" % (readsofar,))
+
+ test_dir = "lld-speed-test"
+ test_archive = f"{test_dir}.tar.xz"
+ if not os.path.isdir(test_dir):
+ if not os.path.isfile(test_archive):
+ choice = input("Download missing test archive (1.1GB) [Y/n/x] ")
+ if not choice in ['', 'Y', 'y']:
+ return False
+
+ url = f"https://s3-us-west-2.amazonaws.com/linker-tests/{test_archive}"
+ urlretrieve(url, test_archive, reporthook)
+ sys.stderr.write("\n")
+
+ # Extract tests
+ p = subprocess.run(["tar", "xf", test_archive], stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE, universal_newlines=True)
+
+ return True
+
+ def cleanup(self):
+ for perm in self.iterate_args():
+ a_out = os.path.join("lld-speed-test", perm.test, "a.out")
+ if os.path.isfile(a_out):
+ os.remove(a_out)
+
+
+ def summary(self):
+ args = self.results["args"]
+ allocators = self.results["allocators"]
+
+
+ for perm in self.iterate_args(args=args):
+ for i, allocator in enumerate(allocators):
+
+ plt.bar([i], self.results["stats"][allocator][perm]["mean"]["task-clock"],
+ label=allocator, color=allocators[allocator]["color"])
+
+ plt.legend(loc="best")
+ plt.ylabel("Zeit in ms")
+ plt.title("Gesamte Laufzeit")
+ plt.savefig(".".join([self.name, perm.test, "runtime", "png"]))
+ plt.clf()
+
+
+
+ # TODO: get memusage
+ # Memusage
+ # self.barplot_single_arg("{VmHWM}",
+ # ylabel='"Max RSS in KB"',
+ # title='"Highwatermark of Vm (VmHWM)"',
+ # filepostfix="rss")
+
+ # self.export_stats_to_csv("VmHWM")
+ self.export_stats_to_csv("task-clock")
+
+ # self.export_stats_to_dataref("VmHWM")
+ self.export_stats_to_dataref("task-clock")
+
+lld = BenchmarkLld()