diff options
-rw-r--r-- | Makefile | 3 | ||||
-rw-r--r-- | rteval/hackbench.py | 2 | ||||
-rw-r--r-- | rteval/kcompile.py | 31 | ||||
-rw-r--r-- | rteval/rteval.py | 81 |
4 files changed, 78 insertions, 39 deletions
@@ -42,6 +42,9 @@ runit: [ -d ./run ] || mkdir run python rteval/rteval.py -D -L -v --workdir=./run --loaddir=./loadsource --duration=$(D) -f ./rteval/rteval.conf -i ./rteval +load: + [ -d ./run ] || mkdir run + python rteval/rteval.py --onlyload -D -L -v --workdir=./run --loaddir=./loadsource -f ./rteval/rteval.conf -i ./rteval sysreport: python rteval/rteval.py -D -v --workdir=./run --loaddir=./loadsource --duration=$(D) -i ./rteval --sysreport diff --git a/rteval/hackbench.py b/rteval/hackbench.py index d545039..42a6ca7 100644 --- a/rteval/hackbench.py +++ b/rteval/hackbench.py @@ -57,7 +57,7 @@ class Hackbench(load.Load): mem = mem * 1024 ratio = float(mem) / float(self.num_cpus) if ratio >= 0.75: - mult = int(self.params.setdefault('jobspercore', 2)) + mult = float(self.params.setdefault('jobspercore', 2)) else: print "hackbench: low memory system (%f GB/core)! Not running\n" % ratio mult = 0 diff --git a/rteval/kcompile.py b/rteval/kcompile.py index 89705c5..e4c9034 100644 --- a/rteval/kcompile.py +++ b/rteval/kcompile.py @@ -90,7 +90,7 @@ class Kcompile(load.Load): err = self.open_logfile("kcompile-build.stderr") # clean up from potential previous run try: - ret = subprocess.call(["make", "-C", self.mydir, "distclean", "allmodconfig"], + ret = subprocess.call(["make", "-C", self.mydir, "mrproper", "allmodconfig"], stdin=null, stdout=out, stderr=err) if ret: raise RuntimeError, "kcompile setup failed: %d" % ret @@ -103,13 +103,7 @@ class Kcompile(load.Load): os.close(out) os.close(err) - def runload(self): - null = os.open("/dev/null", os.O_RDWR) - if self.logging: - out = self.open_logfile("kcompile.stdout") - err = self.open_logfile("kcompile.stderr") - else: - out = err = null + def calc_numjobs(self): mult = int(self.params.setdefault('jobspercore', 1)) mem = self.memsize[0] if self.memsize[1] == 'KB': @@ -124,21 +118,32 @@ class Kcompile(load.Load): else: self.debug("low memory system (%f GB/core)! Dropping jobs to one per core\n" % ratio) njobs = self.num_cpus + return njobs + + def runload(self): + null = os.open("/dev/null", os.O_RDWR) + if self.logging: + out = self.open_logfile("kcompile.stdout") + err = self.open_logfile("kcompile.stderr") + else: + out = err = null + + njobs = self.calc_numjobs() self.debug("starting loop (jobs: %d)" % njobs) self.args = ["make", "-C", self.mydir, - "-j%d" % njobs, - "clean", "bzImage", "modules"] + "-j%d" % njobs ] p = subprocess.Popen(self.args, stdin=null,stdout=out,stderr=err) while not self.stopevent.isSet(): time.sleep(1.0) if p.poll() != None: - p.wait() - self.debug("restarting compile job") + r = p.wait() + self.debug("restarting compile job (exit status: %s)" % r) p = subprocess.Popen(self.args, stdin=null,stdout=out,stderr=err) - self.debug("stopping") + self.debug("out of stopevent loop") if p.poll() == None: + self.debug("killing compile job with SIGTERM") os.kill(p.pid, SIGTERM) p.wait() os.close(null) diff --git a/rteval/rteval.py b/rteval/rteval.py index 073b2aa..aa920b1 100644 --- a/rteval/rteval.py +++ b/rteval/rteval.py @@ -8,8 +8,8 @@ # latency while the loads are running. A report is generated # to show the latencies encountered during the run. # -# Copyright 2009,2010 Clark Williams <williams@redhat.com> -# Copyright 2009,2010 David Sommerseth <davids@redhat.com> +# Copyright 2009,2010,2011 Clark Williams <williams@redhat.com> +# Copyright 2009,2010,2011 David Sommerseth <davids@redhat.com> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -50,7 +50,9 @@ import ethtool import xmlrpclib from datetime import datetime from distutils import sysconfig -sys.path.append("rteval") + +# put local path at start of list to overide installed methods +sys.path.insert(0, "./rteval") import util import load import cyclictest @@ -67,6 +69,8 @@ def sigint_handler(signum, frame): sigint_received = True print "*** SIGINT received - stopping rteval run ***" +def sigterm_handler(signum, frame): + raise RuntimeError, "SIGTERM received!" class RtEval(object): def __init__(self, cmdargs): @@ -94,7 +98,7 @@ class RtEval(object): 'report_interval': '600', 'logging' : False, }, - 'loads' : { + 'loads' : { 'kcompile' : 'module', 'hackbench' : 'module', }, @@ -324,6 +328,10 @@ class RtEval(object): action='store_true', default=False, help='log the output of the loads in the report directory') + parser.add_option("-O", "--onlyload", dest="onlyload", + action='store_true', default=False, + help="only run the loads (don't run measurement threads)") + (self.cmd_options, self.cmd_arguments) = parser.parse_args(args = cmdargs) if self.cmd_options.duration: mult = 1.0 @@ -634,6 +642,8 @@ class RtEval(object): self.services = self.get_services() self.kthreads = self.get_kthreads() + onlyload = self.cmd_options.onlyload + builddir = os.path.join(self.workdir, 'rteval-build') if not os.path.isdir(builddir): os.mkdir(builddir) self.reportfile = os.path.join(self.reportdir, "summary.rpt") @@ -669,8 +679,9 @@ class RtEval(object): self.info("creating load instance for %s" % m.__name__) self.loads.append(m.create(self.config.GetSection(m.__name__))) - self.info("setting up cyclictest") - self.cyclictest = cyclictest.Cyclictest(params=self.config.GetSection('cyclictest')) + if not onlyload: + self.info("setting up cyclictest") + self.cyclictest = cyclictest.Cyclictest(params=self.config.GetSection('cyclictest')) nthreads = 0 try: @@ -687,9 +698,10 @@ class RtEval(object): start = datetime.now() - # start the cyclictest thread - self.info("starting cyclictest") - self.cyclictest.start() + if not onlyload: + # start the cyclictest thread + self.info("starting cyclictest") + self.cyclictest.start() # turn loose the loads self.info("sending start event to all loads") @@ -697,49 +709,67 @@ class RtEval(object): l.startevent.set() nthreads += 1 - # open the loadavg /proc entry - p = open("/proc/loadavg") accum = 0.0 samples = 0 report_interval = int(self.config.GetSection('rteval').report_interval) # wait for time to expire or thread to die - signal.signal(signal.SIGINT, sigint_handler) +# signal.signal(signal.SIGINT, sigint_handler) +# signal.signal(signal.SIGTERM, sigterm_handler) self.info("waiting for duration (%f)" % self.config.duration) stoptime = (time.time() + self.config.duration) currtime = time.time() rpttime = currtime + report_interval + loadcount = 5 while (currtime <= stoptime) and not sigint_received: time.sleep(1.0) - if not self.cyclictest.isAlive(): + if not onlyload and not self.cyclictest.isAlive(): raise RuntimeError, "cyclictest thread died!" if len(threading.enumerate()) < nthreads: raise RuntimeError, "load thread died!" - p.seek(0) - accum += float(p.readline().split()[0]) - samples += 1 + if not loadcount: + # open the loadavg /proc entry + p = open("/proc/loadavg") + load = float(p.readline().split()[0]) + p.close() + accum += load + samples += 1 + loadcount = 5 + #self.debug("current loadavg: %f, running avg: %f (load: %f, samples: %d)" % \ + # (load, accum/samples, load, samples)) + else: + loadcount -= 1 if currtime >= rpttime: left_to_run = stoptime - currtime self.show_remaining_time(left_to_run) rpttime = currtime + report_interval + print "load average: %.2f" % (accum / samples) currtime = time.time() - signal.signal(signal.SIGINT, signal.SIG_DFL) + self.debug("out of measurement loop") +# signal.signal(signal.SIGINT, signal.SIG_DFL) +# signal.signal(signal.SIGTERM, signal.SIG_DFL) + except RuntimeError, e: + print "Runtime error during measurement: %s", e + raise + finally: - # stop cyclictest - self.cyclictest.stopevent.set() + if not onlyload: + # stop cyclictest + self.cyclictest.stopevent.set() # stop the loads self.stop_loads() print "stopping run at %s" % time.asctime() - # wait for cyclictest to finish calculating stats - self.cyclictest.finished.wait() - self.genxml(datetime.now() - start, accum, samples) - self.report() - if self.config.sysreport: - self.run_sysreport() + if not onlyload: + # wait for cyclictest to finish calculating stats + self.cyclictest.finished.wait() + self.genxml(datetime.now() - start, accum, samples) + self.report() + if self.config.sysreport: + self.run_sysreport() def XMLRPC_Send(self): @@ -900,6 +930,7 @@ if __name__ == '__main__': rteval = RtEval(sys.argv[1:]) ec = rteval.rteval() + rteval.debug("exiting with exit code: %d" % ec) sys.exit(ec) except KeyboardInterrupt: sys.exit(0) |