diff options
Diffstat (limited to 'rteval')
-rw-r--r-- | rteval/modules/__init__.py | 71 | ||||
-rw-r--r-- | rteval/modules/loads/__init__.py | 2 | ||||
-rw-r--r-- | rteval/modules/loads/hackbench.py | 10 |
3 files changed, 50 insertions, 33 deletions
diff --git a/rteval/modules/__init__.py b/rteval/modules/__init__.py index 0191767..ff35421 100644 --- a/rteval/modules/__init__.py +++ b/rteval/modules/__init__.py @@ -53,6 +53,7 @@ class rtevalModulePrototype(threading.Thread): self.__events = {"start": threading.Event(), "stop": threading.Event(), "finished": threading.Event()} + self._donotrun = False def _log(self, logtype, msg): @@ -63,6 +64,8 @@ class rtevalModulePrototype(threading.Thread): def isReady(self): "Returns a boolean if the module is ready to run" + if self._donotrun: + return True return self.__ready @@ -118,6 +121,7 @@ class rtevalModulePrototype(threading.Thread): "Required module method, which purpose is to do the initial workload setup, preparing for _WorkloadBuild()" raise NotImplementedError("_WorkloadSetup() method must be implemented in the %s module" % self._name) + def _WorkloadBuild(self): "Required module method, which purpose is to compile additional code needed for the worklaod" raise NotImplementedError("_WorkloadBuild() method must be implemented in the %s module" % self._name) @@ -143,6 +147,11 @@ class rtevalModulePrototype(threading.Thread): raise NotImplementedError("_WorkloadCleanup() method must be implemented in the %s module" % self._name) + def WorkloadWillRun(self): + "Returns True if this workload will be run" + return self._donotrun is False + + def run(self): "Workload thread runner - takes care of keeping the workload running as long as needed" if self.shouldStop(): @@ -151,32 +160,36 @@ class rtevalModulePrototype(threading.Thread): # Initial workload setups self._WorkloadSetup() - # Compile the workload - self._WorkloadBuild() - - # Do final preparations of workload before we're ready to start running - self._WorkloadPrepare() - - # Wait until we're released - while True: - if self.shouldStop(): - return - self.__events["start"].wait(1.0) - if self.shouldStart(): - break - - self._log(Log.DEBUG, "Starting %s workload" % self._module_type) - while not self.shouldStop(): - # Run the workload - self._WorkloadTask() - - if self.shouldStop(): - break - if not self.WorkloadAlive(): - self._log(Log.DEBUG, "%s workload stopped running." % self._module_type) - break - time.sleep(1.0) - self._log(Log.DEBUG, "stopping %s workload" % self._module_type) + if not self._donotrun: + # Compile the workload + self._WorkloadBuild() + + # Do final preparations of workload before we're ready to start running + self._WorkloadPrepare() + + # Wait until we're released + while True: + if self.shouldStop(): + return + self.__events["start"].wait(1.0) + if self.shouldStart(): + break + + self._log(Log.DEBUG, "Starting %s workload" % self._module_type) + while not self.shouldStop(): + # Run the workload + self._WorkloadTask() + + if self.shouldStop(): + break + if not self.WorkloadAlive(): + self._log(Log.DEBUG, "%s workload stopped running." % self._module_type) + break + time.sleep(1.0) + self._log(Log.DEBUG, "stopping %s workload" % self._module_type) + else: + self._log(Log.DEBUG, "Workload was not started") + self._WorkloadCleanup() @@ -404,7 +417,8 @@ start their workloads yet""" self._logger.log(Log.INFO, "Starting %s modules" % self._module_type) for (modname, mod) in self.__modules: mod.start() - self._logger.log(Log.DEBUG, "\t - %s started" % modname) + if mod.WorkloadWillRun(): + self._logger.log(Log.DEBUG, "\t - %s started" % modname) self._logger.log(Log.DEBUG, "Waiting for all %s modules to get ready" % self._module_type) busy = True @@ -460,6 +474,9 @@ start their workloads yet""" self._logger.log(Log.INFO, "Stopping %s modules" % self._module_type) for (modname, mod) in self.__modules: + if not mod.WorkloadWillRun(): + continue + mod.setStop() try: self._logger.log(Log.DEBUG, "\t - Stopping %s" % modname) diff --git a/rteval/modules/loads/__init__.py b/rteval/modules/loads/__init__.py index ca84f47..69de0a8 100644 --- a/rteval/modules/loads/__init__.py +++ b/rteval/modules/loads/__init__.py @@ -70,7 +70,7 @@ class CommandLineLoad(LoadThread): def MakeReport(self): - if not (self.jobs and self.args): + if not (self.jobs and self.args) or self._donotrun: return None rep_n = libxml2.newNode("command_line") diff --git a/rteval/modules/loads/hackbench.py b/rteval/modules/loads/hackbench.py index 6cb0524..53c4739 100644 --- a/rteval/modules/loads/hackbench.py +++ b/rteval/modules/loads/hackbench.py @@ -51,6 +51,8 @@ class Hackbench(CommandLineLoad): else: self._log(Log.INFO, "hackbench: low memory system (%f GB/core)! Not running\n" % ratio) mult = 0 + self._donotrun = True + self.jobs = self.num_cpus * mult self.args = ['hackbench', '-P', @@ -67,11 +69,6 @@ class Hackbench(CommandLineLoad): def _WorkloadPrepare(self): - # if we don't have any jobs just wait for the stop event and return - if self.jobs == 0: - self.WaitForCompletion() - return - self.__nullfp = os.open("/dev/null", os.O_RDWR) if self._logging: self.__out = self.open_logfile("hackbench.stdout") @@ -111,6 +108,9 @@ class Hackbench(CommandLineLoad): def _WorkloadCleanup(self): + if self._donotrun: + return + if self.__hbproc.poll() == None: os.kill(self.__hbproc.pid, SIGKILL) self.__hbproc.wait() |