aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fl.fischer@fau.de>2019-08-22 20:05:48 +0200
committerFlorian Fischer <florian.fl.fischer@fau.de>2019-08-22 20:30:10 +0200
commit2364ca102a265b713f423e7c54ccd118bbecd86a (patch)
treed7618591e53f26eb9d280f1e80cabe03f7534ba5
parenta799b6e3996288ec9fb295bef5a5c4407f8da24c (diff)
downloadallocbench-2364ca102a265b713f423e7c54ccd118bbecd86a.tar.gz
allocbench-2364ca102a265b713f423e7c54ccd118bbecd86a.zip
support chattymalloc as analyze fallback if malt is not available
bench.py saves the benchmark specific result directory in the object member "result_dir". This member is used by the analyze allocators to know where to write the trace files to.
-rwxr-xr-xbench.py65
-rw-r--r--src/allocators/chattymalloc.py4
-rw-r--r--src/allocators/malt.py6
3 files changed, 41 insertions, 34 deletions
diff --git a/bench.py b/bench.py
index d27200e..a1aab65 100755
--- a/bench.py
+++ b/bench.py
@@ -196,12 +196,6 @@ def main():
if args.exclude_benchmarks and bench in args.exclude_benchmarks:
continue
- # Create result dir for this benchmark
- if args.analyse or not args.nosum:
- bench_res_dir = os.path.join(resdir, bench)
- print_info2("Creating benchmark result dir:", bench_res_dir)
- os.makedirs(bench_res_dir, exist_ok=True)
-
try:
bench_module = importlib.import_module(f"src.benchmarks.{bench}")
if not hasattr(bench_module, bench):
@@ -209,6 +203,12 @@ def main():
bench = getattr(bench_module, bench)
+ # Create benchmark result directory
+ bench.result_dir = os.path.abspath(os.path.join(resdir, bench.name))
+ if args.analyse or not args.nosum:
+ print_info2("Creating benchmark result dir:", bench.result_dir)
+ os.makedirs(bench.result_dir, exist_ok=True)
+
if args.load:
bench.load(path=args.load)
@@ -217,34 +217,32 @@ def main():
bench.prepare()
if args.analyse:
+ print_status("Analysing {} ...".format(bench))
if find_cmd("malt") is not None:
- print_status("Analysing {} ...".format(bench))
-
- malt_cmd = "malt -o output:name={}/malt.{}.%3"
- malt_cmd = malt_cmd.format(bench_res_dir, "{perm}")
-
- old_allocs = bench.allocators
- # use malt as allocator
- bench.allocators = {"malt": {"cmd_prefix": malt_cmd,
- "binary_suffix": "",
- "LD_PRELOAD": ""}}
- try:
- bench.run(runs=1)
- except Exception:
- print_error(traceback.format_exc())
- print_error("Skipping analysis of", bench, "!")
-
- # Remove malt from results
- if "malt" in bench.results:
- del(bench.results["malt"])
- if "stats" in bench.results and "malt" in bench.results["stats"]:
- del(bench.results["stats"]["malt"])
-
- # restore allocs
- bench.allocators = old_allocs
-
+ analyse_alloc = "malt"
else:
- print_error("malt not found. Skipping analyse.")
+ print_warning("malt not found. Using chattymalloc.")
+ analyse_alloc = "chattymalloc"
+
+ old_allocs = bench.allocators
+ analyse_alloc_module = importlib.import_module(f"src.allocators.{analyse_alloc}")
+ bench.allocators = {analyse_alloc: getattr(analyse_alloc_module, analyse_alloc).build()}
+
+ try:
+ bench.run(runs=1)
+ except Exception:
+ print_error(traceback.format_exc())
+ print_error("Skipping analysis of", bench, "!")
+
+ # Remove results for analyse_alloc
+ if analyse_alloc in bench.results:
+ del(bench.results[analyse_alloc])
+ if "stats" in bench.results and analyse_alloc in bench.results["stats"]:
+ del(bench.results["stats"][analyse_alloc])
+
+ # restore allocs
+ bench.allocators = old_allocs
+ print(bench.results)
if args.runs > 0:
print_status("Running", bench.name, "...")
@@ -259,7 +257,8 @@ def main():
bench.save()
# Summarize benchmark in benchmark specific resultdir
- if not args.nosum:
+ # Only summarize if we have data.
+ if not args.nosum and (args.runs > 0 or args.load):
os.chdir(bench.name)
print_status("Summarizing", bench.name, "...")
bench.summary()
diff --git a/src/allocators/chattymalloc.py b/src/allocators/chattymalloc.py
index 3079667..6688f51 100644
--- a/src/allocators/chattymalloc.py
+++ b/src/allocators/chattymalloc.py
@@ -1,4 +1,6 @@
import os
from src.allocator import Allocator, builddir
-chattymalloc = Allocator("chattymalloc", LD_PRELOAD=os.path.join(builddir, "chattymalloc.so"), color="xkcd:black")
+chattymalloc = Allocator("chattymalloc",
+ LD_PRELOAD=os.path.join(builddir, "chattymalloc.so"),
+ cmd_prefix="env CHATTYMALLOC_FILE={{result_dir}}/chatty_{{perm}}.txt")
diff --git a/src/allocators/malt.py b/src/allocators/malt.py
new file mode 100644
index 0000000..2a5b647
--- /dev/null
+++ b/src/allocators/malt.py
@@ -0,0 +1,6 @@
+from src.allocator import Allocator
+
+# result_dir and perm are substituted during Benchmark.run
+cmd = "malt -o output:name={{result_dir}}/malt.{{perm}}.%3"
+
+malt = Allocator("malt", cmd_prefix=cmd)