Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bugfix] Reset poll rate every time a test finishes the compilation or run phase #2534

Merged
merged 4 commits into from
Jun 10, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 11 additions & 21 deletions reframe/frontend/executors/policies.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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):
Expand Down Expand Up @@ -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,
Expand All @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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])
Expand Down