diff --git a/reframe/frontend/executors/policies.py b/reframe/frontend/executors/policies.py index 3c7ef313f1..03514734ed 100644 --- a/reframe/frontend/executors/policies.py +++ b/reframe/frontend/executors/policies.py @@ -46,28 +46,16 @@ class _PollController: def __init__(self): self._num_polls = 0 - self._num_tasks = 0 self._sleep_duration = None self._t_init = None - def running_tasks(self, num_tasks): - if self._sleep_duration is None: - self._sleep_duration = self.SLEEP_MIN + def reset_snooze_time(self): + self._sleep_duration = self.SLEEP_MIN + def snooze(self): if self._num_polls == 0: self._t_init = time.time() - else: - if self._num_tasks != num_tasks: - self._sleep_duration = self.SLEEP_MIN - else: - self._sleep_duration = min( - self._sleep_duration*self.SLEEP_INC_RATE, self.SLEEP_MAX - ) - - self._num_tasks = num_tasks - return self - def snooze(self): t_elapsed = time.time() - self._t_init self._num_polls += 1 poll_rate = self._num_polls / t_elapsed if t_elapsed else math.inf @@ -76,6 +64,9 @@ def snooze(self): f'(current poll rate: {poll_rate} polls/s)' ) time.sleep(self._sleep_duration) + self._sleep_duration = min( + self._sleep_duration*self.SLEEP_INC_RATE, self.SLEEP_MAX + ) class SerialExecutionPolicy(ExecutionPolicy, TaskEventListener): @@ -120,7 +111,6 @@ def runcase(self, case): task.skip() raise TaskExit from e - partname = task.testcase.partition.fullname task.setup(task.testcase.partition, task.testcase.environ, sched_flex_alloc_nodes=self.sched_flex_alloc_nodes, @@ -136,13 +126,12 @@ def runcase(self, case): else: sched = partition.scheduler + self._pollctl.reset_snooze_time() while True: sched.poll(task.check.job) if task.run_complete(): break - self._pollctl.running_tasks(1).snooze() - task.run_wait() if not self.skip_sanity_check: task.sanity() @@ -321,6 +310,7 @@ def exit(self): if self._pipeline_statistics: self._init_pipeline_progress(len(self._current_tasks)) + self._pollctl.reset_snooze_time() while self._current_tasks: try: self._poll_tasks() @@ -349,7 +339,7 @@ def exit(self): ) if num_running: - self._pollctl.running_tasks(num_running).snooze() + self._pollctl.snooze() except ABORT_REASONS as e: self._failall(e) raise @@ -565,10 +555,10 @@ def on_task_compile(self, task): pass def on_task_exit(self, task): - pass + self._pollctl.reset_snooze_time() def on_task_compile_exit(self, task): - pass + self._pollctl.reset_snooze_time() def on_task_skip(self, task): msg = str(task.exc_info[1])