[dvsim] Scheduler updates - max_parallel, max_poll
The max_parallel setting previously was a Scheduler class variable. It
has now been moved to the Launcher class, since each launcher variant
has different needs.
Likewise, 2 new features are added - `max_poll` and `poll_freq`. By
default, the max_poll 10K, and the polling frequency is 1 second.
The purpose of adding these knobs is to reduce the polling rate and the
number of jobs polled at a given time. With external launchers such as
LSF and cloud, polling for a job completion could involve multiple steps
and some external command invocations that are time-consuming. These
features help limit the time taken by the Scheduler to poll the entire
set of jobs. If we do not provide a way to fine-tune / adjust these
parameters, DVSim will appear to have hung (or worse, it could crash the
system).
The max_poll needs to cycle through the list of running jobs, rather
than just the first N ones. For example, if there are 5 jobs running [a,
b, c, d, e], and max_poll is set to 2, on the first poll window, it
polls for jobs a and b to complete. Then it polls b and c, followed by e
and a and so on. To allow this to happen, the list of running jobs now
needs to be maintained as a circular linked list, that supports
iterating through the list, while allowing jobs to be added or removed
from the list in realtime. This is achieved in the newly added
`CircularList` class.
Signed-off-by: Srikrishna Iyer <sriyer@google.com>
diff --git a/util/dvsim/LauncherFactory.py b/util/dvsim/LauncherFactory.py
index fdfaaeb..0e7479b 100644
--- a/util/dvsim/LauncherFactory.py
+++ b/util/dvsim/LauncherFactory.py
@@ -4,12 +4,10 @@
import logging as log
import os
-import sys
from Launcher import Launcher
from LocalLauncher import LocalLauncher
from LsfLauncher import LsfLauncher
-from Scheduler import Scheduler
try:
from EdaCloudLauncher import EdaCloudLauncher
@@ -18,7 +16,7 @@
EDACLOUD_LAUNCHER_EXISTS = False
# The chosen launcher class.
-launcher_cls = None
+_LAUNCHER_CLS = None
def set_launcher_type(is_local=False):
@@ -36,29 +34,29 @@
launcher = "local"
Launcher.variant = launcher
- global launcher_cls
+ global _LAUNCHER_CLS
if launcher == "local":
- launcher_cls = LocalLauncher
+ _LAUNCHER_CLS = LocalLauncher
elif launcher == "lsf":
- launcher_cls = LsfLauncher
-
- # The max_parallel setting is not relevant when dispatching with LSF.
- Scheduler.max_parallel = sys.maxsize
+ _LAUNCHER_CLS = LsfLauncher
# These custom launchers are site specific. They may not be committed to
# the open source repo.
elif launcher == "edacloud" and EDACLOUD_LAUNCHER_EXISTS:
- launcher_cls = EdaCloudLauncher
-
- # The max_parallel setting is not relevant when dispatching with
- # EDACloud.
- Scheduler.max_parallel = sys.maxsize
+ _LAUNCHER_CLS = EdaCloudLauncher
else:
log.error("Launcher {} set using DVSIM_LAUNCHER env var does not "
"exist. Using local launcher instead.".format(launcher))
- launcher_cls = LocalLauncher
+ _LAUNCHER_CLS = LocalLauncher
+
+
+def get_launcher_cls():
+ '''Returns the chosen launcher class.'''
+
+ assert _LAUNCHER_CLS is not None
+ return _LAUNCHER_CLS
def get_launcher(deploy):
@@ -67,6 +65,5 @@
'deploy' is an instance of the deploy class to with the launcher is paired.
'''
- global launcher_cls
- assert launcher_cls is not None
- return launcher_cls(deploy)
+ assert _LAUNCHER_CLS is not None
+ return _LAUNCHER_CLS(deploy)