Skip to main content

35. Time Slot Reservation for Variant Scheduling

Status: Accepted Date: 2025-07-06

Context

In the Mercury experimental framework, we need to run multiple variants of tournaments (e.g., Read-only, Live Trading, A/B/H experiments) concurrently without them interfering with each other. Using complex cron schedules with different minute offsets for each variant is fragile, hard to reason about, and prone to overlapping execution if not calculated perfectly. A simpler, more robust scheduling mechanism is needed.

Decision

We will use a simple time slot reservation system. The schedule will be divided into repeating 2-hour blocks. Within each block, each major variant type is assigned a fixed, non-overlapping time slot.

For example, within each 2-hour block:

  • 0-30 minutes: Reserved for the R (Read-only) instance.
  • 30-60 minutes: Reserved for the W (Live Trading) instance.
  • 60-120 minutes: Reserved for the ABH (A/B/H Experimental) instance.

The application logic will determine which tournament to run based on the current time and its assigned slot, completely eliminating the need for complex cron offset calculations.

Consequences

Positive:

  • Simplicity & Predictability: The schedule is extremely easy to understand and reason about. There is no complex math involved in figuring out what should be running at any given time.
  • Guaranteed Separation: It is impossible for different variant types to run at the same time, preventing resource conflicts and interference.
  • Robustness: The system is much less fragile than cron offsets. Changes to one slot do not affect the others.

Negative:

  • Rigidity: This approach is less flexible than a fully dynamic cron-based schedule. All slots are of a fixed size, and the schedule is the same for every 2-hour block.
  • Inefficient Resource Use: If one variant finishes its work early, its slot remains unused until the next block. There is no dynamic "filling" of empty time.

Mitigation:

  • Fit-for-Purpose: This system is designed for a structured, long-running experimental framework where predictability and reliability are more important than maximizing resource utilization or scheduling flexibility.
  • Clear Documentation: The time slot system will be clearly documented as a core constraint of the experimental framework.
  • Sufficient Slot Size: The slot sizes will be chosen to be more than sufficient for the expected workload of each variant, reducing the risk of tasks overrunning their allotted time.