aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fl.fischer@fau.de>2019-09-21 18:38:25 +0200
committerFlorian Fischer <florian.fl.fischer@fau.de>2019-09-21 18:38:25 +0200
commit213e5625a9aa677230f261fcee01086f9ee1f850 (patch)
tree21a422f2152f0f1921b431199acb69cc7568e07b
parent84eec0baba49bff0a5c2b64834bc2d75d687e7b5 (diff)
downloadallocbench-213e5625a9aa677230f261fcee01086f9ee1f850.tar.gz
allocbench-213e5625a9aa677230f261fcee01086f9ee1f850.zip
replace AllocatorSources with Artifacts
-rw-r--r--src/allocator.py150
-rw-r--r--src/allocators/all.py4
-rw-r--r--src/allocators/glibc.py34
-rw-r--r--src/allocators/hoard.py25
-rw-r--r--src/allocators/installed_allocators.py10
-rw-r--r--src/allocators/jemalloc.py26
-rw-r--r--src/allocators/malt.py4
-rw-r--r--src/allocators/mesh.py28
-rw-r--r--src/allocators/mimalloc.py27
-rw-r--r--src/allocators/scalloc.py31
-rw-r--r--src/allocators/snmalloc.py27
-rw-r--r--src/allocators/speedymalloc.py2
-rw-r--r--src/allocators/streamflow.py23
-rw-r--r--src/allocators/supermalloc.py30
-rw-r--r--src/allocators/tbbmalloc.py25
-rw-r--r--src/allocators/tcmalloc.py24
16 files changed, 188 insertions, 282 deletions
diff --git a/src/allocator.py b/src/allocator.py
index 41d66c7..26866dd 100644
--- a/src/allocator.py
+++ b/src/allocator.py
@@ -37,98 +37,27 @@ for line in subprocess.run(["ldconfig", "-v"], stdout=subprocess.PIPE,
if not line.startswith('\t'):
LIBRARY_PATH += line
-BUILDDIR = os.path.join(src.globalvars.builddir, "allocators")
+BUILDDIR = src.globalvars.allocbuilddir
SRCDIR = os.path.join(src.globalvars.allocbuilddir, "src")
if not os.path.isdir(SRCDIR):
os.makedirs(SRCDIR)
-class AllocatorSources:
- """Class representing sources an allocator is build from
-
- AllocatorSources can retrieve, prepare and reset their managed sources
- """
- def __init__(self, name, retrieve_cmds=None, prepare_cmds=None, reset_cmds=None):
- self.name = name
- self.dir = os.path.join(SRCDIR, self.name)
- self.patchdir = os.path.join(src.globalvars.allocsrcdir, self.name)
- self.retrieve_cmds = retrieve_cmds or []
- self.prepare_cmds = prepare_cmds or []
- self.reset_cmds = reset_cmds or []
-
- def run_cmds(self, function, cwd=SRCDIR):
- """Helper to run retrieve, prepare or reset commands"""
- print_status(function, self.name, "...")
-
- cmds = getattr(self, function+"_cmds")
-
- stdout = subprocess.PIPE if src.globalvars.verbosity < 2 else None
-
- for cmd in cmds:
- proc = subprocess.run(cmd, shell=True, cwd=cwd,
- stderr=subprocess.PIPE, stdout=stdout,
- universal_newlines=True)
-
- if proc.returncode:
- print_error(function, self.name, "failed with", proc.returncode,
- file=sys.stderr)
- print_debug(proc.stderr, file=sys.stderr)
- return False
- return True
-
- def prepare(self):
- """Prepare the managed sources for building
-
- If the sources aren't available yet they are retrieved.
- Otherwise they are reset.
- """
- if not os.path.isdir(self.dir):
- if (not self.run_cmds("retrieve") or
- not self.run_cmds("prepare", cwd=self.dir)):
-
- shutil.rmtree(self.dir, ignore_errors=True)
- exit(1)
- else:
- self.reset()
-
- def reset(self):
- """Reset the managed sources"""
- if not self.run_cmds("reset", cwd=self.dir):
- exit(1)
-
- def patch(self, patches):
- """Patch the managed sources using patch(1)"""
- if not patches:
- return
-
- stdout = subprocess.PIPE if src.globalvars.verbosity < 2 else None
- cwd = os.path.join(SRCDIR, self.name)
-
- print_status("Patching", self.name, "...")
- for patch in patches:
- with open(patch.format(patchdir=self.patchdir), "rb") as patch_file:
- proc = subprocess.run("patch -p1", shell=True, cwd=cwd,
- stderr=subprocess.PIPE, stdout=stdout,
- input=patch_file.read())
-
- if proc.returncode:
- print_error("Patching of", self.name, "failed.",
- file=sys.stderr)
- print_debug(proc.stderr, file=sys.stderr)
- exit(1)
-
-
class Allocator:
"""Allocator base class
- It builds the allocator and produces a for allocbench usable allocator dict"""
- allowed_attributes = ["binary_suffix", "version", "sources", "build_cmds",
- "LD_PRELOAD", "cmd_prefix", "color", "patches",
- "LD_LIBRARY_PATH"]
+ An Allocator can contain an Artifact which provides the allocator sources,
+ patches, and instructions to build the allocator.
+ Allocator.build will compile the allocator and produce a for allocbench usable
+ allocator dict"""
+ allowed_attributes = ["binary_suffix", "cmd_prefix", "LD_PRELOAD", "LD_LIBRARY_PATH", "color",
+ "sources", "version", "patches", "prepare_cmds",
+ "build_cmds"]
def __init__(self, name, **kwargs):
self.name = name
+ self.srcdir = os.path.join(SRCDIR, self.name)
self.dir = os.path.join(BUILDDIR, self.name)
# Update attributes
self.__dict__.update((k, v) for k, v in kwargs.items()
@@ -139,12 +68,48 @@ class Allocator:
if not hasattr(self, attr):
setattr(self, attr, None)
+ def prepare(self):
+ """Prepare the allocators sources"""
+ if not self.sources and os.path.exists(self.srcdir):
+ return
+
+ print_status("Preparing", self.name, "...")
+ self.sources.provide(self.version, self.srcdir)
+
+ if self.patches:
+ stdout = subprocess.PIPE if src.globalvars.verbosity < 2 else None
+ cwd = os.path.join(SRCDIR, self.name)
+
+ print_status("Patching", self.name, "...")
+ for patch in self.patches:
+ with open(patch.format(patchdir=self.patchdir), "rb") as patch_file:
+ proc = subprocess.run("patch -p1", shell=True, cwd=cwd,
+ stderr=subprocess.PIPE, stdout=stdout,
+ input=patch_file.read())
+
+ if proc.returncode:
+ print_debug(proc.stderr, file=sys.stderr)
+ raise Exception(f"Patching of {self.name} failed.")
+
+ if self.prepare_cmds:
+ print_status("Run prepare commands", self.name, "...")
+ stdout = subprocess.PIPE if src.globalvars.verbosity < 2 else None
+
+ for cmd in self.prepare_cmds:
+ proc = subprocess.run(cmd, shell=True, cwd=self.srcdir,
+ stderr=subprocess.PIPE, stdout=stdout,
+ universal_newlines=True)
+
+ if proc.returncode:
+ print_debug(proc.stderr, file=sys.stderr)
+ raise Exception(f'Prepare command "{cmd}" failed with exitcode: {proc.returncode}.')
+
def build(self):
- """Build the allocator if needed and produce allocator dict"""
+ """Build the allocator if needed and produce an allocator dict"""
build_needed = not os.path.isdir(self.dir)
buildtimestamp_path = os.path.join(self.dir, ".buildtime")
- print_info2(f"Building {self.name}...")
+ print_status("Building", self.name, "...")
if not build_needed:
print_info2("Old build found. Comparing build time with mtime")
@@ -157,33 +122,25 @@ class Allocator:
build_needed = timestamp < modtime
print_debug("Time of last build:", timestamp.isoformat())
- print_debug("Last modification of allocators file:",
- modtime.isoformat())
+ print_debug("Last modification of allocators file:", modtime.isoformat())
print_info2("" if build_needed else "No " + "build needed")
if build_needed:
- if self.sources:
- self.sources.prepare()
- self.sources.patch(self.patches)
+ self.prepare()
if self.build_cmds:
- print_status("Building", self.name, "...")
-
stdout = subprocess.PIPE if src.globalvars.verbosity < 2 else None
for cmd in self.build_cmds:
- cmd = cmd.format(**{"dir": self.dir,
- "srcdir": self.sources.dir})
+ cmd = cmd.format(dir=self.dir, srcdir=self.srcdir)
proc = subprocess.run(cmd, cwd=BUILDDIR, shell=True,
stderr=subprocess.PIPE, stdout=stdout,
universal_newlines=True)
if proc.returncode:
- print_error(cmd, "failed with:", proc.returncode)
print_debug(proc.stderr, file=sys.stderr)
- print_error("Building", self.name, "failed ...")
shutil.rmtree(self.dir, ignore_errors=True)
- exit(2)
+ raise Exception(f'Build command "{cmd}" failed with exitcode: {proc.returncode}')
with open(buildtimestamp_path, "w") as buildtimestamp_file:
print_info2("Save build time to:", buildtimestamp_path)
@@ -196,13 +153,10 @@ class Allocator:
"LD_LIBRARY_PATH": self.LD_LIBRARY_PATH or "",
"color": self.color}
- paths = {"dir": self.dir}
- paths["srcdir"] = self.sources.dir if self.sources is not None else ""
-
for attr in ["LD_PRELOAD", "LD_LIBRARY_PATH", "cmd_prefix"]:
value = getattr(self, attr, "") or ""
if value != "":
- value = value.format(**paths)
+ value = value.format(dir=self.dir, srcdir=self.srcdir)
res_dict[attr] = value
print_debug("Resulting dictionary:", res_dict)
diff --git a/src/allocators/all.py b/src/allocators/all.py
index 6b3b46a..a2b502a 100644
--- a/src/allocators/all.py
+++ b/src/allocators/all.py
@@ -24,12 +24,12 @@ from src.allocators.hoard import hoard
from src.allocators.mesh import mesh
from src.allocators.scalloc import scalloc
from src.allocators.supermalloc import supermalloc
-from src.allocators.llalloc import llalloc
+# from src.allocators.llalloc import llalloc
from src.allocators.tbbmalloc import tbbmalloc
from src.allocators.mimalloc import mimalloc
from src.allocators.snmalloc import snmalloc
allocators = [*src.allocators.glibcs.allocators, tcmalloc, tcmalloc_nofs,
- jemalloc, hoard, mesh, supermalloc, scalloc, llalloc, tbbmalloc,
+ jemalloc, hoard, mesh, supermalloc, scalloc, tbbmalloc, # llalloc, # streamflow,
mimalloc, snmalloc]
diff --git a/src/allocators/glibc.py b/src/allocators/glibc.py
index c322427..3c739fe 100644
--- a/src/allocators/glibc.py
+++ b/src/allocators/glibc.py
@@ -17,52 +17,48 @@
"""Glibc definitions"""
-from src.allocator import Allocator, AllocatorSources, LIBRARY_PATH
-
-VERSION = 2.29
-
-GLIBC_SRC = AllocatorSources("glibc",
- retrieve_cmds=["git clone git://sourceware.org/git/glibc.git"],
- prepare_cmds=[f"git checkout glibc-{VERSION}"],
- reset_cmds=["git reset --hard"])
+from src.allocator import Allocator, LIBRARY_PATH
+from src.artifact import GitArtifact
class Glibc(Allocator):
"""Glibc definition for allocbench
Glibcs are loaded using their own supplied loader"""
+
+ sources = GitArtifact("glibc", "git://sourceware.org/git/glibc.git")
+
def __init__(self, name, **kwargs):
- kwargs["sources"] = GLIBC_SRC
configure_args = ""
if "configure_args" in kwargs:
configure_args = kwargs["configure_args"]
- del(kwargs["configure_args"])
-
- kwargs["build_cmds"] = ["mkdir -p glibc-build",
- "cd glibc-build; {srcdir}/configure --prefix={dir} " + configure_args,
- "cd glibc-build; make",
- "cd glibc-build; make install"]
+ del kwargs["configure_args"]
- kwargs["cmd_prefix"] = ("{dir}/lib/ld-linux-x86-64.so.2 --library-path {dir}/lib:"
- + LIBRARY_PATH)
+ self.build_cmds = ["mkdir -p glibc-build",
+ "cd glibc-build; {srcdir}/configure --prefix={dir} " + configure_args,
+ "cd glibc-build; make",
+ "cd glibc-build; make install"]
- # kwargs["LD_LIBRARY_PATH"] = "{dir}/lib:" + library_path
+ self.cmd_prefix = "{dir}/lib/ld-linux-x86-64.so.2 --library-path {dir}/lib:" + LIBRARY_PATH
super().__init__(name, **kwargs)
-glibc = Glibc("glibc", color="xkcd:red")
+glibc = Glibc("glibc", version="glibc-2.29", color="xkcd:red")
glibc_notc = Glibc("glibc-noThreadCache",
configure_args="--disable-experimental-malloc",
+ version="glibc-2.29",
color="xkcd:maroon")
glibc_nofs = Glibc("glibc-noFalsesharing",
patches=["{patchdir}/glibc_2.29_no_passive_falsesharing.patch"],
+ version="glibc-2.29",
color="xkcd:pink")
glibc_nofs_fancy = Glibc("glibc-noFalsesharingClever",
patches=["{patchdir}/glibc_2.29_no_passive_falsesharing_fancy.patch"],
+ version="glibc-2.29",
color="xkcd:orange")
diff --git a/src/allocators/hoard.py b/src/allocators/hoard.py
index cc2061a..7e94d79 100644
--- a/src/allocators/hoard.py
+++ b/src/allocators/hoard.py
@@ -17,26 +17,23 @@
"""Hoard allocator definition for allocbench"""
-from src.allocator import Allocator, AllocatorSources
-
-
-sources = AllocatorSources("Hoard",
- retrieve_cmds=["git clone https://github.com/emeryberger/Hoard.git"],
- reset_cmds=["git reset --hard"])
+from src.allocator import Allocator
+from src.artifact import GitArtifact
class Hoard(Allocator):
"""Hoard allocator"""
- def __init__(self, name, **kwargs):
- kwargs["sources"] = sources
- kwargs["LD_PRELOAD"] = "{dir}/libhoard.so"
- kwargs["build_cmds"] = ["cd {srcdir}/src; make",
- "mkdir -p {dir}",
- "ln -f -s {srcdir}/src/libhoard.so {dir}/libhoard.so"]
- kwargs["requirements"] = ["clang"]
+ sources = GitArtifact("Hoard", "https://github.com/emeryberger/Hoard.git")
+
+ def __init__(self, name, **kwargs):
+ self.LD_PRELOAD = "{dir}/libhoard.so"
+ self.build_cmds = ["cd {srcdir}/src; make",
+ "mkdir -p {dir}",
+ "ln -f -s {srcdir}/src/libhoard.so {dir}/libhoard.so"]
+ self.requirements = ["clang"]
super().__init__(name, **kwargs)
-hoard = Hoard("Hoard", color="xkcd:brown")
+hoard = Hoard("Hoard", version="aa6d31700d5368a9f5ede3d62731247c8d9f0ebb", color="xkcd:brown")
diff --git a/src/allocators/installed_allocators.py b/src/allocators/installed_allocators.py
index 9a11d04..d45755a 100644
--- a/src/allocators/installed_allocators.py
+++ b/src/allocators/installed_allocators.py
@@ -22,11 +22,11 @@ import subprocess
# TODO: add more allocators
MAYBE_ALLOCATORS = ["tcmalloc", "jemalloc", "hoard"]
-allocators = {"libc": {"cmd_prefix": "",
- "binary_suffix": "",
- "LD_PRELOAD": "",
- "LD_LIBRARY_PATH": "",
- "color": "C1"}}
+allocators = {"libc": {"cmd_prefix": "",
+ "binary_suffix": "",
+ "LD_PRELOAD": "",
+ "LD_LIBRARY_PATH": "",
+ "color": "C1"}}
for i, t in enumerate(MAYBE_ALLOCATORS):
try:
diff --git a/src/allocators/jemalloc.py b/src/allocators/jemalloc.py
index 4484362..18e3055 100644
--- a/src/allocators/jemalloc.py
+++ b/src/allocators/jemalloc.py
@@ -17,26 +17,24 @@
"""jemalloc definition for allocbench"""
-from src.allocator import Allocator, AllocatorSources
-
-VERSION = "5.1.0"
-
-sources = AllocatorSources("jemalloc",
- retrieve_cmds=["git clone https://github.com/jemalloc/jemalloc.git"],
- prepare_cmds=[f"git checkout {VERSION}", "./autogen.sh"])
+from src.allocator import Allocator
+from src.artifact import GitArtifact
class Jemalloc(Allocator):
"""jemalloc allocator"""
- def __init__(self, name, **kwargs):
- kwargs["sources"] = sources
- kwargs["LD_PRELOAD"] = "{srcdir}/lib/libjemalloc.so"
- kwargs["build_cmds"] = ["cd {srcdir}; ./configure --prefix={dir}",
- "cd {srcdir}; make -j4",
- "mkdir -p {dir}"]
+ sources = GitArtifact("jemalloc", "https://github.com/jemalloc/jemalloc.git")
+
+ def __init__(self, name, **kwargs):
+ self.LD_PRELOAD = "{dir}/libjemalloc.so"
+ self.prepare_cmds = ["./autogen.sh"]
+ self.build_cmds = ["cd {srcdir}; ./configure --prefix={dir}",
+ "cd {srcdir}; make -j4",
+ "mkdir -p {dir}",
+ "ln -f -s {srcdir}/lib/libjemalloc.so {dir}/libjemalloc.so"]
super().__init__(name, **kwargs)
-jemalloc = Jemalloc("jemalloc", color="xkcd:yellow")
+jemalloc = Jemalloc("jemalloc", version="5.1.0", color="xkcd:yellow")
diff --git a/src/allocators/malt.py b/src/allocators/malt.py
index 599e8ff..34fd9cc 100644
--- a/src/allocators/malt.py
+++ b/src/allocators/malt.py
@@ -24,6 +24,4 @@ of a program. See https://github.com/memtt/malt for more details
from src.allocator import Allocator
# result_dir and perm are substituted during Benchmark.run
-cmd = "malt -q -o output:name={{result_dir}}/malt.{{perm}}.%3"
-
-malt = Allocator("malt", cmd_prefix=cmd)
+malt = Allocator("malt", cmd_prefix="malt -q -o output:name={{result_dir}}/malt.{{perm}}.%3")
diff --git a/src/allocators/mesh.py b/src/allocators/mesh.py
index f8b7c16..2391e23 100644
--- a/src/allocators/mesh.py
+++ b/src/allocators/mesh.py
@@ -17,29 +17,23 @@
"""Mesh definition for allocbench"""
-from src.allocator import Allocator, AllocatorSources
-
-sources = AllocatorSources("Mesh",
- retrieve_cmds=["git clone https://github.com/plasma-umass/Mesh"],
- reset_cmds=["git reset --hard"])
-
-# sources = src.allocator.GitAllocatorSources("Mesh",
-# "https://github.com/plasma-umass/Mesh",
-# "adsf0982345")
+from src.allocator import Allocator
+from src.artifact import GitArtifact
class Mesh(Allocator):
"""Mesh allocator"""
- def __init__(self, name, **kwargs):
- kwargs["sources"] = sources
- kwargs["LD_PRELOAD"] = "{srcdir}/libmesh.so"
- kwargs["build_cmds"] = ["cd {srcdir}; git submodule update --init",
- "cd {srcdir}; ./configure",
- "cd {srcdir}; make -j 4",
- "mkdir -p {dir}"]
+ sources = GitArtifact("Mesh", "https://github.com/plasma-umass/Mesh")
+
+ def __init__(self, name, **kwargs):
+ self.LD_PRELOAD = "{dir}/libmesh.so"
+ self.build_cmds = ["cd {srcdir}; ./configure",
+ "cd {srcdir}; make -j 4",
+ "mkdir -p {dir}",
+ "ln -f -s {srcdir}/libmesh.so {dir}/libmesh.so"]
super().__init__(name, **kwargs)
-mesh = Mesh("Mesh", color="xkcd:mint")
+mesh = Mesh("Mesh", version="4a1012cee990cb98cc1ea0294a836f467b29be02", color="xkcd:mint")
diff --git a/src/allocators/mimalloc.py b/src/allocators/mimalloc.py
index 2f84fe1..6931217 100644
--- a/src/allocators/mimalloc.py
+++ b/src/allocators/mimalloc.py
@@ -17,28 +17,23 @@
"""mimalloc definition for allocbench"""
-from src.allocator import Allocator, AllocatorSources
-
-VERSION = "master"
-
-MIMALLOC_SRC = AllocatorSources("mimalloc",
- ["git clone https://github.com/microsoft/mimalloc"],
- [f"git checkout {VERSION}"],
- ["git reset --hard"])
+from src.allocator import Allocator
+from src.artifact import GitArtifact
class Mimalloc(Allocator):
"""mimalloc allocator"""
- def __init__(self, name, **kwargs):
- kwargs["sources"] = MIMALLOC_SRC
- kwargs["LD_PRELOAD"] = "{dir}/libmimalloc.so"
- kwargs["build_cmds"] = ["mkdir -p {dir}",
- "cd {dir}; cmake {srcdir}",
- "cd {dir}; make"]
- kwargs["requirements"] = ["cmake"]
+ sources = GitArtifact("mimalloc", "https://github.com/microsoft/mimalloc")
+
+ def __init__(self, name, **kwargs):
+ self.LD_PRELOAD = "{dir}/libmimalloc.so"
+ self.build_cmds = ["mkdir -p {dir}",
+ "cd {dir}; cmake {srcdir}",
+ "cd {dir}; make"]
+ self.requirements = ["cmake"]
super().__init__(name, **kwargs)
-mimalloc = Mimalloc("mimalloc")
+mimalloc = Mimalloc("mimalloc", version="v1.0.8")
diff --git a/src/allocators/scalloc.py b/src/allocators/scalloc.py
index 0b3d3cf..82ef8d1 100644
--- a/src/allocators/scalloc.py
+++ b/src/allocators/scalloc.py
@@ -17,32 +17,25 @@
"""Scalloc definition for allocbench"""
-from src.allocator import Allocator, AllocatorSources
-from src.util import print_error
-
-
-VERSION = "v1.0.0"
-
-SCALLOC_SRC = AllocatorSources("scalloc",
- retrieve_cmds=["git clone https://github.com/cksystemsgroup/scalloc"],
- prepare_cmds=[f"git checkout {VERSION}",
- "cd {srcdir}; tools/make_deps.sh",
- "cd {srcdir}; build/gyp/gyp --depth=. scalloc.gyp"],
- reset_cmds=["git reset --hard"])
+from src.allocator import Allocator
+from src.artifact import GitArtifact
class Scalloc(Allocator):
"""Scalloc allocator"""
- def __init__(self, name, **kwargs):
- kwargs["sources"] = SCALLOC_SRC
+ sources = GitArtifact("scalloc", "https://github.com/cksystemsgroup/scalloc")
+
+ def __init__(self, name, **kwargs):
+ self.prepare_cmds = ["tools/make_deps.sh",
+ "build/gyp/gyp --depth=. scalloc.gyp"]
- kwargs["build_cmds"] = ["cd {srcdir}; BUILDTYPE=Release make",
- "mkdir -p {dir}"]
+ self.build_cmds = ["cd {srcdir}; BUILDTYPE=Release make",
+ "mkdir -p {dir}"]
- kwargs["LD_PRELOAD"] = "{srcdir}/out/Release/lib.target/libscalloc.so"
+ self.LD_PRELOAD = "{srcdir}/out/Release/lib.target/libscalloc.so"
- kwargs["patches"] = ["{patchdir}/scalloc_fix_log.patch"]
+ self.patches = ["{patchdir}/scalloc_fix_log.patch"]
super().__init__(name, **kwargs)
@@ -57,4 +50,4 @@ sysctl vm.overcommit_memory=1
return super().build()
-scalloc = Scalloc("scalloc", color="xkcd:magenta")
+scalloc = Scalloc("scalloc", color="xkcd:magenta", version="v1.0.0")
diff --git a/src/allocators/snmalloc.py b/src/allocators/snmalloc.py
index 0496196..7f27e4b 100644
--- a/src/allocators/snmalloc.py
+++ b/src/allocators/snmalloc.py
@@ -17,28 +17,23 @@
"""Snmalloc definition for allocbench"""
-from src.allocator import Allocator, AllocatorSources
-
-VERSION = "master"
-
-SNMALLOC_SRC = AllocatorSources("snmalloc",
- ["git clone https://github.com/microsoft/snmalloc"],
- [f"git checkout {VERSION}"],
- ["git reset --hard"])
+from src.allocator import Allocator
+from src.artifact import GitArtifact
class Snmalloc(Allocator):
"""snmalloc allocator"""
- def __init__(self, name, **kwargs):
- kwargs["sources"] = SNMALLOC_SRC
- kwargs["LD_PRELOAD"] = "{dir}/libsnmallocshim.so"
- kwargs["build_cmds"] = ["mkdir -p {dir}",
- "cd {dir}; cmake -G Ninja {srcdir} -DCMAKE_BUILD_TYPE=Release",
- "cd {dir}; ninja"]
- kwargs["requirements"] = ["cmake", "ninja", "clang"]
+ sources = GitArtifact("snmalloc", "https://github.com/microsoft/snmalloc")
+
+ def __init__(self, name, **kwargs):
+ self.LD_PRELOAD = "{dir}/libsnmallocshim.so"
+ self.build_cmds = ["mkdir -p {dir}",
+ "cd {dir}; cmake -G Ninja {srcdir} -DCMAKE_BUILD_TYPE=Release",
+ "cd {dir}; ninja"]
+ self.requirements = ["cmake", "ninja", "clang"]
super().__init__(name, **kwargs)
-snmalloc = Snmalloc("snmalloc")
+snmalloc = Snmalloc("snmalloc", version="0.2")
diff --git a/src/allocators/speedymalloc.py b/src/allocators/speedymalloc.py
index 9df3d7d..0cf6836 100644
--- a/src/allocators/speedymalloc.py
+++ b/src/allocators/speedymalloc.py
@@ -26,4 +26,4 @@ import os
from src.allocator import Allocator, BUILDDIR
speedymalloc = Allocator("speedymalloc", LD_PRELOAD=os.path.join(BUILDDIR, "speedymalloc.so"),
- color="xkcd:dark")
+ color="xkcd:dark")
diff --git a/src/allocators/streamflow.py b/src/allocators/streamflow.py
index 73aede9..005b9cb 100644
--- a/src/allocators/streamflow.py
+++ b/src/allocators/streamflow.py
@@ -17,25 +17,24 @@
"""Streamflow allocator definition for allocbench"""
-from src.allocator import Allocator, AllocatorSources
-
-
-sources = AllocatorSources("streamflow",
- retrieve_cmds=["git clone https://github.com/scotts/streamflow"],
- reset_cmds=["git reset --hard"])
+from src.allocator import Allocator
+from src.artifact import GitArtifact
class Streamflow(Allocator):
"""Streamflow allocator"""
+
+ sources = GitArtifact("streamflow", "https://github.com/scotts/streamflow")
+
def __init__(self, name, **kwargs):
- kwargs["sources"] = sources
- kwargs["LD_PRELOAD"] = "{dir}/libstreamflow.so"
- kwargs["build_cmds"] = ["cd {srcdir}; make",
- "mkdir -p {dir}",
- "ln -f -s {srcdir}/libstreamflow.so {dir}/libstreamflow.so"]
+ self.LD_PRELOAD = "{dir}/libstreamflow.so"
+ self.build_cmds = ["cd {srcdir}; make",
+ "mkdir -p {dir}",
+ "ln -f -s {srcdir}/libstreamflow.so {dir}/libstreamflow.so"]
super().__init__(name, **kwargs)
-streamflow = Streamflow("Streamflow", color="xkcd:light brown")
+streamflow = Streamflow("Streamflow", version="8ac345c0f69ec9e7af02f3555c2c97eaa07a442e",
+ color="xkcd:light brown")
diff --git a/src/allocators/supermalloc.py b/src/allocators/supermalloc.py
index 130dd47..f0a192a 100644
--- a/src/allocators/supermalloc.py
+++ b/src/allocators/supermalloc.py
@@ -17,29 +17,23 @@
"""SuperMalloc definition for allocbench"""
-from src.allocator import Allocator, AllocatorSources
-
-import src.allocator
-
-VERSION = "709663fb81ba091b0a78058869a644a272f4163d"
-
-sources = AllocatorSources("SuperMalloc",
- retrieve_cmds=["git clone https://github.com/kuszmaul/SuperMalloc"],
- prepare_cmds=[f"git checkout {VERSION}"],
- reset_cmds=["git reset --hard"])
-
+from src.allocator import Allocator
+from src.artifact import GitArtifact
class SuperMalloc(Allocator):
"""SuperMalloc allocator"""
- def __init__(self, name, **kwargs):
- kwargs["sources"] = sources
- kwargs["LD_PRELOAD"] = "{srcdir}/release/lib/libsupermalloc.so"
- kwargs["build_cmds"] = ["cd {srcdir}/release; make",
- "mkdir -p {dir}"]
- kwargs["patches"] = ["{patchdir}/remove_faulty_aligned_alloc_test.patch"]
+ sources = GitArtifact("SuperMalloc", "https://github.com/kuszmaul/SuperMalloc")
+
+ def __init__(self, name, **kwargs):
+ self.LD_PRELOAD = "{dir}/libsupermalloc.so"
+ self.build_cmds = ["cd {srcdir}/release; make",
+ "mkdir -p {dir}",
+ "ln -f -s {srcdir}/release/lib/libsupermalloc.so {dir}/libsupermalloc.so"]
+ self.patches = ["{patchdir}/remove_faulty_aligned_alloc_test.patch"]
super().__init__(name, **kwargs)
-supermalloc = SuperMalloc("SuperMalloc", color="xkcd:lime")
+supermalloc = SuperMalloc("SuperMalloc", color="xkcd:lime",
+ version="709663fb81ba091b0a78058869a644a272f4163d")
diff --git a/src/allocators/tbbmalloc.py b/src/allocators/tbbmalloc.py
index aa50253..3dca919 100644
--- a/src/allocators/tbbmalloc.py
+++ b/src/allocators/tbbmalloc.py
@@ -17,27 +17,22 @@
"""tbbmalloc definition for allocbench"""
-from src.allocator import Allocator, AllocatorSources
-
-VERSION = "2019_U8"
-
-source = AllocatorSources("tbb",
- ["git clone https://github.com/intel/tbb.git"],
- [f"git checkout {VERSION}"],
- ["git reset --hard"])
+from src.allocator import Allocator
+from src.artifact import GitArtifact
class TBBMalloc(Allocator):
"""tbbmalloc allocator"""
- def __init__(self, name, **kwargs):
- kwargs["sources"] = source
- kwargs["LD_PRELOAD"] = "{dir}/libtbbmalloc.so"
- kwargs["build_cmds"] = ["cd {srcdir}; make tbbmalloc -j4",
- "mkdir -p {dir}",
- 'ln -f -s $(find {srcdir} -executable -name "*libtbbmalloc_proxy.so*" | head -1) {dir}/libtbbmalloc.so']
+ source = GitArtifact("tbb", "https://github.com/intel/tbb.git"),
+
+ def __init__(self, name, **kwargs):
+ self.LD_PRELOAD = "{dir}/libtbbmalloc.so"
+ self.build_cmds = ["cd {srcdir}; make tbbmalloc -j4",
+ "mkdir -p {dir}",
+ 'ln -f -s $(find {srcdir} -executable -name "*libtbbmalloc_proxy.so*" | head -1) {dir}/libtbbmalloc.so']
super().__init__(name, **kwargs)
-tbbmalloc = TBBMalloc("tbbmalloc", color="xkcd:green")
+tbbmalloc = TBBMalloc("tbbmalloc", color="xkcd:green", version="2019_U8")
diff --git a/src/allocators/tcmalloc.py b/src/allocators/tcmalloc.py
index 916da88..f81f88b 100644
--- a/src/allocators/tcmalloc.py
+++ b/src/allocators/tcmalloc.py
@@ -17,30 +17,28 @@
"""TCMalloc definition for allocbench"""
-from src.allocator import Allocator, AllocatorSources
-
-VERSION = 2.7
-
-TCMALLOC_SRC = AllocatorSources("tcmalloc",
- ["git clone https://github.com/gperftools/gperftools.git tcmalloc"],
- [f"git checkout gperftools-{VERSION}", "./autogen.sh"],
- ["git reset --hard"])
+from src.allocator import Allocator
+from src.artifact import GitArtifact
class TCMalloc(Allocator):
"""TCMalloc allocator"""
+
+ sources = GitArtifact("tcmalloc", "https://github.com/gperftools/gperftools.git")
+
def __init__(self, name, **kwargs):
- kwargs["sources"] = TCMALLOC_SRC
- kwargs["LD_PRELOAD"] = "{dir}/lib/libtcmalloc.so"
- kwargs["build_cmds"] = ["cd {srcdir}; ./configure --prefix={dir}",
- "cd {srcdir}; make install -j4"]
+ self.LD_PRELOAD = "{dir}/lib/libtcmalloc.so"
+ self.prepare_cmds = ["./autogen.sh"]
+ self.build_cmds = ["cd {srcdir}; ./configure --prefix={dir}",
+ "cd {srcdir}; make install -j4"]
super().__init__(name, **kwargs)
-tcmalloc = TCMalloc("TCMalloc", color="xkcd:blue")
+tcmalloc = TCMalloc("TCMalloc", color="xkcd:blue", version="gperftools-2.7")
tcmalloc_nofs = TCMalloc("TCMalloc-NoFalsesharing",
patches=["{patchdir}/tcmalloc_2.7_no_active_falsesharing.patch"],
+ version="gperftools-2.7",
color="xkcd:navy")