aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/allocators.py16
-rw-r--r--src/benchmark.py10
-rw-r--r--src/facter.py22
-rw-r--r--src/globalvars.py3
-rw-r--r--src/mysql.py12
5 files changed, 44 insertions, 19 deletions
diff --git a/src/allocators.py b/src/allocators.py
index 717c500..26fab5b 100644
--- a/src/allocators.py
+++ b/src/allocators.py
@@ -3,12 +3,14 @@
import os
import subprocess
+import src.globalvars
+
maybe_allocators = ["tcmalloc", "jemalloc", "hoard"]
-allocators = {"libc": {"cmd_prefix" : "",
- "binary_suffix" : "",
- "LD_PRELOAD" : "",
- "color" : "C1"}}
+src.globalvars.allocators = {"libc": {"cmd_prefix" : "",
+ "binary_suffix" : "",
+ "LD_PRELOAD" : "",
+ "color" : "C1"}}
for i, t in enumerate(maybe_allocators):
try:
@@ -17,7 +19,9 @@ for i, t in enumerate(maybe_allocators):
universal_newlines=True).stdout.strip()
if path != "":
- allocators[t] = {"cmd_prefix": "", "binary_suffix": "",
- "LD_PRELOAD": path, "color": "C"+str(i+2)}
+ src.globalvars.allocators[t] = {"cmd_prefix": "",
+ "binary_suffix": "",
+ "LD_PRELOAD": path,
+ "color": "C"+str(i+2)}
except:
pass
diff --git a/src/benchmark.py b/src/benchmark.py
index 18934f7..7d3207f 100644
--- a/src/benchmark.py
+++ b/src/benchmark.py
@@ -9,7 +9,6 @@ import pickle
import shutil
import subprocess
-from src.allocators import allocators
import src.globalvars
from src.util import *
@@ -25,7 +24,7 @@ class Benchmark (object):
"measure_cmd": "perf stat -x, -d",
"cmd": "true",
- "allocators": allocators,
+ "allocators": src.globalvars.allocators,
}
@staticmethod
@@ -41,7 +40,7 @@ class Benchmark (object):
steps = 10
# Special thread counts
- nthreads = set([1, cpus/2, cpus, cpus*factor])
+ nthreads = set([1, int(cpus/2), cpus, cpus*factor])
nthreads.update(range(steps, cpus * factor + 1, steps))
nthreads = list(nthreads)
nthreads.sort()
@@ -64,6 +63,7 @@ class Benchmark (object):
self.results = {}
self.results["args"] = self.args
self.results["allocators"] = self.allocators
+ self.results["facts"] = {"libcs": {}}
self.results.update({t: {} for t in self.allocators})
if not hasattr(self, "requirements"):
@@ -125,13 +125,17 @@ class Benchmark (object):
if not is_exe(r):
print_error("requirement:", r, "not found")
return False
+ else:
+ self.results["facts"]["libcs"][exe_file] = src.facter.get_libc_version(bin=exe_file)
# Search in PATH
else:
found = False
for path in os.environ["PATH"].split(os.pathsep):
exe_file = os.path.join(path, r)
if is_exe(exe_file):
+ self.results["facts"]["libcs"][exe_file] = src.facter.get_libc_version(bin=exe_file)
found = True
+ break
if not found:
print_error("requirement:", r, "not found")
diff --git a/src/facter.py b/src/facter.py
index 4e68665..6f6ba87 100644
--- a/src/facter.py
+++ b/src/facter.py
@@ -1,18 +1,22 @@
+import multiprocessing
+import os
import platform
import sys
-def get_uname():
- return " ".join(platform.uname())
+import src.globalvars as gv
-def get_kernel_version():
- return get_uname().split()[2]
-def get_hostname():
- return platform.uname().node
+# Populate src.globalvars.facts on import
+_uname = platform.uname()
+gv.facts["hostname"] = _uname.node
+gv.facts["system"] = _uname.system
+gv.facts["kernel"] = _uname.release
+gv.facts["arch"] = _uname.machine
+gv.facts["cpus"] = multiprocessing.cpu_count()
+
+with open(os.path.join(gv.builddir, "ccinfo"), "r") as ccinfo:
+ gv.facts["cc"] = ccinfo.readlines()[-1][:-1]
-def get_cc_version():
- with open("build/ccinfo", "r") as ccinfo:
- return ccinfo.readlines()[-1][:-1]
def get_libc_version(bin=None):
bin = bin or sys.executable
diff --git a/src/globalvars.py b/src/globalvars.py
index fb80a26..0dcfd2c 100644
--- a/src/globalvars.py
+++ b/src/globalvars.py
@@ -7,6 +7,9 @@ facts = {}
"""Verbosity level -1: quiet, 0: status, 1: info, 2: stdout of subcommands, 3: debug info"""
verbosity = 0
+"""Dict holding the allocators to compare"""
+allocators = {}
+
"""File were the allocators definitions are loaded from"""
allocators_file = None
diff --git a/src/mysql.py b/src/mysql.py
index 2f0bce5..0ba820e 100644
--- a/src/mysql.py
+++ b/src/mysql.py
@@ -1,3 +1,4 @@
+import atexit
import copy
import matplotlib.pyplot as plt
import numpy as np
@@ -9,7 +10,7 @@ from subprocess import PIPE
import sys
from time import sleep
-from src.allocators import allocators
+from src.globalvars import allocators
from src.benchmark import Benchmark
from src.util import *
@@ -42,6 +43,9 @@ class Benchmark_MYSQL(Benchmark):
self.measure_cmd = ""
self.requirements = ["mysqld", "sysbench"]
+
+ atexit.register(self.terminate_server)
+
super().__init__()
def start_and_wait_for_server(self, cmd_prefix=""):
@@ -54,6 +58,12 @@ class Benchmark_MYSQL(Benchmark):
sleep(10)
return self.server.poll() is None
+ def terminate_server(self):
+ if self.server:
+ if self.server.poll() == None:
+ print_info("Killing still running mysql server")
+ self.server.kill()
+
def prepare(self):
if not super().prepare():
return False