@@ -15,19 +15,18 @@ use std::pin::Pin;
1515use std:: future:: poll_fn;
1616use std:: task:: Poll ;
1717
18- use restate_clock:: RoughTimestamp ;
1918use restate_storage_api:: StorageError ;
2019use restate_storage_api:: vqueue_table:: scheduler:: { RunAction , SchedulerAction , YieldAction } ;
21- use restate_storage_api:: vqueue_table:: { EntryKey , ScanVQueueTable , VQueueStore , stats:: WaitStats } ;
22- use restate_types:: time:: MillisSinceEpoch ;
20+ use restate_storage_api:: vqueue_table:: { EntryKey , ScanVQueueTable , VQueueStore } ;
2321use restate_types:: vqueues:: VQueueId ;
22+ use restate_worker_api:: { SchedulingStatus , VQueueSchedulerStatus } ;
2423
2524use crate :: VQueueEvent ;
2625use crate :: VQueuesMetaCache ;
2726use crate :: metric_definitions:: publish_scheduler_decision_metrics;
2827
2928use self :: drr:: DRRScheduler ;
30- use self :: resource_manager:: { PermitBuilder , ReservedResources , ResourceKind } ;
29+ use self :: resource_manager:: { PermitBuilder , ReservedResources } ;
3130use self :: vqueue_state:: DetailedEligibility ;
3231
3332mod clock;
@@ -46,79 +45,16 @@ type UnconfirmedAssignments = hashbrown::HashMap<EntryKey, PermitBuilder>;
4645
4746slotmap:: new_key_type! { pub ( crate ) struct VQueueHandle ; }
4847
49- /// A public view of the scheduler's status of a single vqueue.
50- ///
51- /// This struct provides introspection into the current scheduling state, and
52- /// wait statistics for a vqueue.
53- #[ derive( Debug , Clone , Default ) ]
54- pub struct VQueueSchedulerStatus {
55- /// Statistics about the wait time experienced by the head item in the vqueue.
56- pub wait_stats : WaitStats ,
57- /// Number of items remaining in the running stage.
58- pub remaining_running : u32 ,
59- /// Number of items waiting in the inbox stage.
60- pub waiting_inbox : u64 ,
61- /// The current scheduling status of this vqueue.
62- pub status : SchedulingStatus ,
63- }
64-
65- /// The current scheduling status of a vqueue.
66- ///
67- /// This enum represents the various states a vqueue can be in from the
68- /// scheduler's perspective.
69- #[ derive( Debug , Clone , Default , PartialEq , Eq ) ]
70- pub enum SchedulingStatus {
71- #[ default]
72- /// The vqueue is not tracked by the scheduler (e.g., it has no items).
73- Dormant ,
74- /// The vqueue is empty.
75- Empty ,
76- /// The vqueue head is ready to be scheduled and it's in the inbox/running stage.
77- Ready ,
78- /// The vqueue is throttled until the specified time.
79- Throttled {
80- /// When the throttle expires.
81- until : MillisSinceEpoch ,
82- /// The scope of throttling (global or per-vqueue).
83- scope : ThrottleScope ,
84- } ,
85- /// The vqueue is scheduled to be woken up at the given time because the head
86- /// item is scheduled to run at that time.
87- Scheduled {
88- /// When the head item becomes visible.
89- at : RoughTimestamp ,
90- } ,
91- /// The vqueue is blocked on invoker global capacity.
92- BlockedOn ( ResourceKind ) ,
93- /// The vqueue is waiting to acquire a lock of a VO.
94- BlockedOnLock ,
95- /// The vqueue is waiting for concurrency tokens. Concurrency tokens are released
96- /// when currently running items are completed or (in some cases) when running items
97- /// are parked.
98- WaitingConcurrencyTokens ,
99- }
100-
101- impl From < DetailedEligibility > for SchedulingStatus {
102- fn from ( value : DetailedEligibility ) -> Self {
103- match value {
104- DetailedEligibility :: EligibleRunning | DetailedEligibility :: EligibleInbox => {
105- SchedulingStatus :: Ready
106- }
107- DetailedEligibility :: Scheduled ( ts) => SchedulingStatus :: Scheduled { at : ts } ,
108- DetailedEligibility :: Empty => SchedulingStatus :: Empty ,
48+ fn status_from_detailed_eligibility ( value : DetailedEligibility ) -> SchedulingStatus {
49+ match value {
50+ DetailedEligibility :: EligibleRunning | DetailedEligibility :: EligibleInbox => {
51+ SchedulingStatus :: Ready
10952 }
53+ DetailedEligibility :: Scheduled ( ts) => SchedulingStatus :: Scheduled { at : ts } ,
54+ DetailedEligibility :: Empty => SchedulingStatus :: Empty ,
11055 }
11156}
11257
113- /// The scope at which throttling is applied.
114- #[ derive( Debug , Clone , Copy , PartialEq , Eq ) ]
115- pub enum ThrottleScope {
116- /// Throttling is applied globally across all vqueues.
117- Global ,
118- /// Throttling is applied to a specific vqueue.
119- VQueue ,
120- }
121-
12258#[ derive( Default , Debug ) ]
12359pub struct Decisions {
12460 // Vqueue ids are ordered by partition key, this enables us to group
0 commit comments