Skip to content

Commit

Permalink
Implement no consideration period in STRL-based schedulers.|
Browse files Browse the repository at this point in the history
  • Loading branch information
sukritkalra committed Mar 24, 2024
1 parent 355e4e1 commit c66ef75
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
7 changes: 7 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,13 @@
"the available tasks (in µs). The default value is to pack until the maximum "
"deadline for each batch of available tasks.",
)
flags.DEFINE_integer(
"scheduler_plan_ahead_no_consideration_gap",
0,
"The length of time gap (in µs) for which the reconsiderations are frozen. "
"From the current time to the consideration gap, any tasks placed will not be "
"reconsidered for rescheduling.",
)
flags.DEFINE_integer(
"scheduler_time_discretization",
1,
Expand Down
26 changes: 21 additions & 5 deletions schedulers/tetrisched_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,10 @@ class TetriSchedScheduler(BaseScheduler):
log to files with the format "gurobi_{sim_time}.log".
_flags (`Optional[absl.flags]`): The runtime flags that are used to initialize
a logger instance.
plan_ahead_no_consideration_gap (`EventTime`): The time gap after the current
time for which plan ahead is not considered malleable. Any tasks placed
during this time will not be reconsidered for scheduling in a particular
run.
"""

def __init__(
Expand All @@ -181,6 +185,7 @@ def __init__(
max_occupancy_threshold: float = 0.8,
finer_discretization_at_prev_solution: bool = False,
finer_discretization_window: EventTime = EventTime(5, EventTime.Unit.US),
plan_ahead_no_consideration_gap: EventTime = EventTime.zero(),
):
if preemptive:
raise ValueError("TetrischedScheduler does not support preemption.")
Expand Down Expand Up @@ -231,6 +236,7 @@ def __init__(
_flags.scheduler_selective_rescheduling_sample_size if _flags else 5
)
self._plan_ahead_multiplier: int = 2
self._plan_ahead_no_consideration_gap = plan_ahead_no_consideration_gap

# Scheduler configuration.
self._scheduler_configuration = tetrisched.SchedulerConfig()
Expand Down Expand Up @@ -1096,11 +1102,21 @@ def construct_task_strl(
retract_schedules,
)

# If the task is already running or scheduled and we're not reconsidering
# previous schedulings, we block off all the time discretizations from the
# task's start until it completes.
if task.state == TaskState.RUNNING or (
task.state == TaskState.SCHEDULED and not retract_schedules
# We block off all the time discretizations from the task's start until it
# completes if any one of the following conditions hold:
# 1. The Task is already running (we do not consider preemption for now).
# 2. The Task is scheduled and the scheduler was specifically requested to
# not retract schedules.
# 3. The intended start time of the task falls within the no consideration
# period from the current time.
if (
task.state == TaskState.RUNNING # 1.
or (task.state == TaskState.SCHEDULED and not retract_schedules) # 2.
or ( # 3.
task.state == TaskState.SCHEDULED
and task.current_placement.placement_time
< current_time + self._plan_ahead_no_consideration_gap
)
):
# Find the Partition where the task is running or to be scheduled.
scheduled_partition = partitions.get_partition_for_worker_id(
Expand Down

0 comments on commit c66ef75

Please sign in to comment.