[dvsim] Do weighted scheduling of jobs
This patch adds rough weights to each target (build, run, cov etc). If
the slots are fully utilized and just one becomes available, the
weighted scheduling will prefer the earlier targets than the latter. If
multiple tests pass and more slots are available, then it distrubutes
the available slots to each remaining target by their assigned weights.
The weights are set such that builds have the highest preference,
followed by coverage tasks followed by runs. The reason for doing so is
as follows:
Lets say that all build are complete and only the simulation and
coverage jobs are queued up. If all tests of AES are complete, then its
coverage tasks will end up starving until ALL tests in ALL other blocks
are complete. With weighted allocation of dispatch slots, AES coverage
tasks will complete sooner, providing us an early preview of the
results, rather than having to wait 3+ hours for the rest of the
simulation to finish.
Weights are currently set based on relative importance. We can always
adjust them as needed.
Signed-off-by: Srikrishna Iyer <sriyer@google.com>
diff --git a/util/dvsim/Deploy.py b/util/dvsim/Deploy.py
index e055b81..e209801 100644
--- a/util/dvsim/Deploy.py
+++ b/util/dvsim/Deploy.py
@@ -26,6 +26,15 @@
# be joined with '&&' instead of a space.
cmds_list_vars = []
+ # Represents the weight with which a job of this target is scheduled. These
+ # initial weights set for each of the targets below are roughly inversely
+ # proportional to their average runtimes. These are subject to change in
+ # future. Lower the runtime, the higher chance the it gets scheduled. It is
+ # useful to customize this only in case of targets that may coexist at a
+ # time.
+ # TODO: Allow these to be set in the HJson.
+ weight = 1
+
def __str__(self):
return (pprint.pformat(self.__dict__)
if log.getLogger().isEnabledFor(VERBOSE) else self.full_name)
@@ -265,6 +274,7 @@
target = "build"
cmds_list_vars = ["pre_build_cmds", "post_build_cmds"]
+ weight = 5
def __init__(self, build_mode, sim_cfg):
self.build_mode_obj = build_mode
@@ -480,6 +490,7 @@
"""Abstraction for merging coverage databases."""
target = "cov_merge"
+ weight = 10
def __init__(self, run_items, sim_cfg):
# Construct the cov_db_dirs right away from the run_items. This is a
@@ -536,6 +547,7 @@
"""Abstraction for coverage report generation. """
target = "cov_report"
+ weight = 10
def __init__(self, merge_job, sim_cfg):
super().__init__(sim_cfg)