aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/histogram.py27
-rwxr-xr-xscripts/paper_plots.py87
-rwxr-xr-xscripts/print_facts.py10
3 files changed, 88 insertions, 36 deletions
diff --git a/scripts/histogram.py b/scripts/histogram.py
index 2bf6779..f1f8464 100755
--- a/scripts/histogram.py
+++ b/scripts/histogram.py
@@ -16,7 +16,6 @@
#
# You should have received a copy of the GNU General Public License
# along with allocbench. If not, see <http://www.gnu.org/licenses/>.
-
"""Plot an interactive histogram from malt or chattymalloc output file"""
import argparse
@@ -28,17 +27,29 @@ import sys
import matplotlib.pyplot as plt
-currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
+currentdir = os.path.dirname(
+ os.path.abspath(inspect.getfile(inspect.currentframe())))
parentdir = os.path.dirname(currentdir)
sys.path.insert(0, parentdir)
def main():
- parser = argparse.ArgumentParser(description="Plot histograms using a malt or chattymalloc output file")
- parser.add_argument("input_file", help="path to malt or chattymalloc output file", type=str)
- parser.add_argument("-e", "--export", help="export to csv", action="store_true")
- parser.add_argument("-n", "--no-ascii", help="don't output a ascii histogram", action="store_true")
- parser.add_argument("-i", "--interactive", help="open interactive matplotlib histogram plots",
+ parser = argparse.ArgumentParser(
+ description="Plot histograms using a malt or chattymalloc output file")
+ parser.add_argument("input_file",
+ help="path to malt or chattymalloc output file",
+ type=str)
+ parser.add_argument("-e",
+ "--export",
+ help="export to csv",
+ action="store_true")
+ parser.add_argument("-n",
+ "--no-ascii",
+ help="don't output a ascii histogram",
+ action="store_true")
+ parser.add_argument("-i",
+ "--interactive",
+ help="open interactive matplotlib histogram plots",
action="store_true")
args = parser.parse_args()
@@ -87,7 +98,6 @@ def main():
else:
sizes_bigger_32K.append(size * amount)
-
plt.figure(0)
plt.hist(sizes_smaller_4K, 200)
plt.title("Sizes smaller than 4K")
@@ -105,5 +115,6 @@ def main():
plt.title("All sizes")
plt.show()
+
if __name__ == "__main__":
main()
diff --git a/scripts/paper_plots.py b/scripts/paper_plots.py
index 49ec15d..f79cf3a 100755
--- a/scripts/paper_plots.py
+++ b/scripts/paper_plots.py
@@ -24,7 +24,8 @@ import inspect
import os
import sys
-currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
+currentdir = os.path.dirname(
+ os.path.abspath(inspect.getfile(inspect.currentframe())))
parentdir = os.path.dirname(currentdir)
sys.path.insert(0, parentdir)
@@ -36,15 +37,24 @@ from allocbench.util import print_status, print_warn, print_error
from allocbench.util import print_license_and_exit
ALLOCATOR_NAMES = [a.name for a in paper_allocators]
-SURVEY_ALLOCATORS = [a.name for a in paper_allocators if not '-' in a.name or a.name not in ["speedymalloc", "bumpptr"]]
+SURVEY_ALLOCATORS = [
+ a.name for a in paper_allocators
+ if not '-' in a.name or a.name not in ["speedymalloc", "bumpptr"]
+]
TCMALLOCS = [a.name for a in paper_allocators if a.name.startswith("TCMalloc")]
-ALIGNED_ALLOCATORS = [a.name for a in paper_allocators if a.name.endswith("-Aligned")]
+ALIGNED_ALLOCATORS = [
+ a.name for a in paper_allocators if a.name.endswith("-Aligned")
+]
def falsesharing_plots(falsesharing):
args = falsesharing.results["args"]
- falsesharing.results["allocators"] = {k: v for k, v in falsesharing.results["allocators"].items() if k in ALLOCATOR_NAMES}
+ falsesharing.results["allocators"] = {
+ k: v
+ for k, v in falsesharing.results["allocators"].items()
+ if k in ALLOCATOR_NAMES
+ }
plt.pgfplot_legend(falsesharing, columns=5)
@@ -53,12 +63,17 @@ def falsesharing_plots(falsesharing):
for allocator in falsesharing.results["allocators"]:
sequential_perm = falsesharing.Perm(bench=bench, threads=1)
- for perm in falsesharing.iterate_args_fixed({"bench": bench}, args=args):
- for i, measure in enumerate(falsesharing.results[allocator][perm]):
+ for perm in falsesharing.iterate_args_fixed({"bench": bench},
+ args=args):
+ for i, measure in enumerate(
+ falsesharing.results[allocator][perm]):
sequential_time = float(falsesharing.results[allocator]
- [sequential_perm][i]["time"])
- measure["speedup"] = sequential_time / float(measure["time"])
- measure["l1chache_misses"] = float(measure["L1-dcache-load-misses"]) / float(measure["L1-dcache-loads"]) * 100
+ [sequential_perm][i]["time"])
+ measure["speedup"] = sequential_time / float(
+ measure["time"])
+ measure["l1chache_misses"] = float(
+ measure["L1-dcache-load-misses"]) / float(
+ measure["L1-dcache-loads"]) * 100
# delete and recalculate stats
del falsesharing.results["stats"]
@@ -67,7 +82,8 @@ def falsesharing_plots(falsesharing):
# pgfplots
for bench in args["bench"]:
plt.pgfplot(falsesharing,
- falsesharing.iterate_args_fixed({"bench": bench}, args=args),
+ falsesharing.iterate_args_fixed({"bench": bench},
+ args=args),
"int(perm.threads)",
"{speedup}",
xlabel="Threads",
@@ -75,9 +91,14 @@ def falsesharing_plots(falsesharing):
title=f"{bench}: Speedup",
postfix=f"{bench}.speedup")
+
def blowup_plots(blowup):
args = blowup.results["args"]
- blowup.results["allocators"] = {k: v for k, v in blowup.results["allocators"].items() if k in ALLOCATOR_NAMES}
+ blowup.results["allocators"] = {
+ k: v
+ for k, v in blowup.results["allocators"].items()
+ if k in ALLOCATOR_NAMES
+ }
# hack ideal rss in data set
blowup.results["allocators"]["Ideal-RSS"] = {"color": "xkcd:gold"}
@@ -86,11 +107,11 @@ def blowup_plots(blowup):
blowup.results["stats"]["Ideal-RSS"][perm] = {
"mean": {
"VmHWM": 1024 * 100
- },
+ },
"std": {
"VmHWM": 0
- }
}
+ }
plt.pgfplot(blowup,
blowup.iterate_args(args),
@@ -103,9 +124,13 @@ def blowup_plots(blowup):
axis_attr="\txtick=data,\n\tsymbolic x coords={blowup}",
bar=True)
+
def loop_plots(loop):
args = loop.results["args"]
- loop.results["allocators"] = {k: v for k, v in loop.results["allocators"].items() if k in ALLOCATOR_NAMES}
+ loop.results["allocators"] = {
+ k: v
+ for k, v in loop.results["allocators"].items() if k in ALLOCATOR_NAMES
+ }
plt.pgfplot(loop,
loop.iterate_args_fixed({"threads": 40}, args),
@@ -116,9 +141,10 @@ def loop_plots(loop):
title="Loop: 40 threads",
postfix="threads.40")
+
def mysqld_plots(mysql):
args = mysql.results["args"]
-# mysql.results["allocators"] = {k: v for k, v in mysql.results["allocators"].items() if k in SURVEY_ALLOCATORS}
+ # mysql.results["allocators"] = {k: v for k, v in mysql.results["allocators"].items() if k in SURVEY_ALLOCATORS}
plt.pgfplot(mysql,
mysql.iterate_args(args),
@@ -142,9 +168,14 @@ def mysqld_plots(mysql):
plt.pgfplot_legend(mysql, columns=5)
+
def keydb_plots(keydb):
args = keydb.results["args"]
- keydb.results["allocators"] = {k: v for k, v in keydb.results["allocators"].items() if k in SURVEY_ALLOCATORS}
+ keydb.results["allocators"] = {
+ k: v
+ for k, v in keydb.results["allocators"].items()
+ if k in SURVEY_ALLOCATORS
+ }
for fixed_arg in args:
loose_arg = [a for a in args if a != fixed_arg][0]
@@ -159,20 +190,26 @@ def keydb_plots(keydb):
postfix=f"{fixed_arg}.{arg_value}",
bar=True)
+
def summarize(benchmarks=None, exclude_benchmarks=None):
"""summarize the benchmarks in the resdir"""
cwd = os.getcwd()
- for benchmark, func in {"blowup": blowup_plots, "falsesharing": falsesharing_plots,
- "mysql": mysqld_plots, "keydb": keydb_plots,
- "loop": loop_plots}.items():
+ for benchmark, func in {
+ "blowup": blowup_plots,
+ "falsesharing": falsesharing_plots,
+ "mysql": mysqld_plots,
+ "keydb": keydb_plots,
+ "loop": loop_plots
+ }.items():
if benchmarks and not benchmark in benchmarks:
continue
if exclude_benchmarks and benchmark in exclude_benchmarks:
continue
- bench_module = importlib.import_module(f"allocbench.benchmarks.{benchmark}")
+ bench_module = importlib.import_module(
+ f"allocbench.benchmarks.{benchmark}")
if not hasattr(bench_module, benchmark):
print_error(f"{benchmark} has no member {benchmark}")
@@ -188,7 +225,8 @@ def summarize(benchmarks=None, exclude_benchmarks=None):
print_status(f"Summarizing {bench.name} ...")
- res_dir = os.path.join(allocbench.globalvars.resdir, bench.name, "paper")
+ res_dir = os.path.join(allocbench.globalvars.resdir, bench.name,
+ "paper")
if not os.path.isdir(res_dir):
os.makedirs(res_dir)
os.chdir(res_dir)
@@ -216,9 +254,10 @@ def main():
"--exclude-benchmarks",
help="benchmarks to exclude",
nargs='+')
- parser.add_argument("--latex-preamble",
- help="latex code to include in the preamble of generated standalones",
- type=str)
+ parser.add_argument(
+ "--latex-preamble",
+ help="latex code to include in the preamble of generated standalones",
+ type=str)
args = parser.parse_args()
diff --git a/scripts/print_facts.py b/scripts/print_facts.py
index 389028e..ec9404c 100755
--- a/scripts/print_facts.py
+++ b/scripts/print_facts.py
@@ -16,7 +16,6 @@
#
# You should have received a copy of the GNU General Public License
# along with allocbench. If not, see <http://www.gnu.org/licenses/>.
-
"""Print facts about an allocbench result directory"""
import argparse
@@ -25,7 +24,8 @@ import inspect
import os
import sys
-CURRENTDIR = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
+CURRENTDIR = os.path.dirname(
+ os.path.abspath(inspect.getfile(inspect.currentframe())))
PARENTDIR = os.path.dirname(CURRENTDIR)
sys.path.insert(0, PARENTDIR)
@@ -36,7 +36,8 @@ from allocbench.util import print_error
def main():
- parser = argparse.ArgumentParser(description="Print facts about an allocbench result directory")
+ parser = argparse.ArgumentParser(
+ description="Print facts about an allocbench result directory")
parser.add_argument("results", help="path to allocbench results", type=str)
args = parser.parse_args()
@@ -49,7 +50,8 @@ def main():
os.chdir(args.results)
for benchmark in BENCHMARKS:
- bench_module = importlib.import_module(f"allocbench.benchmarks.{benchmark}")
+ bench_module = importlib.import_module(
+ f"allocbench.benchmarks.{benchmark}")
if not hasattr(bench_module, benchmark):
print_error(f"{benchmark} has no member {benchmark}")