pub(crate) struct Scheduler<'a> {Show 22 fields
pub(crate) skel: BpfSkel<'a>,
pub(crate) monitor_interval: Duration,
pub(crate) cells: HashMap<u32, Cell>,
pub(crate) prev_cell_stats: [[u64; 6]; 256],
pub(crate) prev_cell_running_ns: [u64; 256],
pub(crate) prev_cell_own_ns: [u64; 256],
pub(crate) prev_cell_lent_ns: [u64; 256],
pub(crate) metrics: Metrics,
pub(crate) stats_server: Option<StatsServer<(), Metrics>>,
pub(crate) last_configuration_seq: Option<u32>,
pub(crate) last_cpuset_seq: u32,
pub(crate) cell_manager: Option<CellManager>,
pub(crate) enable_borrowing: bool,
pub(crate) enable_rebalancing: bool,
pub(crate) rebalance_threshold: f64,
pub(crate) rebalance_cooldown: Duration,
pub(crate) demand_smoothing: f64,
pub(crate) smoothed_util: [f64; 256],
pub(crate) last_rebalance: Instant,
pub(crate) rebalance_count: u64,
pub(crate) epoll: Epoll,
pub(crate) stats_waker: EventFd,
}Fields§
§skel: BpfSkel<'a>§monitor_interval: Duration§cells: HashMap<u32, Cell>§prev_cell_stats: [[u64; 6]; 256]§prev_cell_running_ns: [u64; 256]§prev_cell_own_ns: [u64; 256]§prev_cell_lent_ns: [u64; 256]§metrics: Metrics§stats_server: Option<StatsServer<(), Metrics>>§last_configuration_seq: Option<u32>§last_cpuset_seq: u32Last observed cpuset_seq for cpuset change detection
cell_manager: Option<CellManager>Optional cell manager for –cell-parent-cgroup mode
enable_borrowing: boolWhether CPU borrowing is enabled
enable_rebalancing: boolWhether demand-based rebalancing is enabled
rebalance_threshold: f64Utilization spread threshold for triggering rebalancing
rebalance_cooldown: DurationMinimum duration between rebalancing events
demand_smoothing: f64EWMA smoothing factor for demand tracking
smoothed_util: [f64; 256]EWMA-smoothed utilization per cell
last_rebalance: InstantLast time rebalancing was performed
rebalance_count: u64Number of rebalancing events
epoll: EpollEpoll instance for waiting on multiple fds (inotify, stats wakeup)
stats_waker: EventFdEventFd to wake up main loop when stats are requested
Implementations§
Source§impl<'a> Scheduler<'a>
impl<'a> Scheduler<'a>
pub(crate) fn validate_args(opts: &Opts) -> Result<()>
pub(crate) fn init( opts: &Opts, open_object: &'a mut MaybeUninit<OpenObject>, ) -> Result<Self>
pub(crate) fn run(&mut self, shutdown: Arc<AtomicBool>) -> Result<UserExitInfo>
Sourcepub(crate) fn apply_initial_cells(&mut self) -> Result<()>
pub(crate) fn apply_initial_cells(&mut self) -> Result<()>
Apply initial cell assignments discovered at startup
Sourcepub(crate) fn process_cell_events(&mut self) -> Result<()>
pub(crate) fn process_cell_events(&mut self) -> Result<()>
Process cell manager events (new/destroyed cgroups)
Sourcepub(crate) fn compute_and_apply_cell_config(
&mut self,
new_cell_ids: &[u32],
) -> Result<Vec<CpuAssignment>>
pub(crate) fn compute_and_apply_cell_config( &mut self, new_cell_ids: &[u32], ) -> Result<Vec<CpuAssignment>>
Compute cell configuration from CellManager and apply it to BPF.
When rebalancing is enabled and there is existing utilization data,
uses demand-weighted CPU assignment instead of equal-weight. New cells
(listed in new_cell_ids) are seeded to the average smoothed_util of
existing cells so they start with a fair share rather than zero.
Returns the CPU assignments for use with format_cell_config.
Sourcepub(crate) fn maybe_rebalance(&mut self) -> Result<()>
pub(crate) fn maybe_rebalance(&mut self) -> Result<()>
Check if rebalancing should be triggered and apply demand-weighted CPU assignments.
Sourcepub(crate) fn apply_cell_config(
&mut self,
cell_assignments: &[(u64, u32)],
cpu_assignments: &[CpuAssignment],
) -> Result<()>
pub(crate) fn apply_cell_config( &mut self, cell_assignments: &[(u64, u32)], cpu_assignments: &[CpuAssignment], ) -> Result<()>
Apply cell configuration to BPF.
Writes the cell and CPU assignments to the BPF config struct and triggers the BPF program to apply the configuration.
pub(crate) fn get_metrics(&self) -> Metrics
pub(crate) fn calculate_distribution_stats( &self, queue_counts: &[u64; 4], global_queue_decisions: u64, scope_queue_decisions: u64, scope_affn_viols: u64, scope_steals: u64, ) -> Result<DistributionStats>
pub(crate) fn update_and_log_global_queue_stats( &mut self, global_queue_decisions: u64, cell_stats_delta: &[[u64; 6]; 256], ) -> Result<()>
pub(crate) fn update_and_log_cell_queue_stats( &mut self, global_queue_decisions: u64, cell_stats_delta: &[[u64; 6]; 256], ) -> Result<()>
pub(crate) fn log_all_queue_stats( &mut self, cell_stats_delta: &[[u64; 6]; 256], ) -> Result<()>
pub(crate) fn calculate_cell_stat_delta( &mut self, cpu_ctxs: &[cpu_ctx], ) -> Result<[[u64; 6]; 256]>
Sourcepub(crate) fn collect_metrics(&mut self) -> Result<()>
pub(crate) fn collect_metrics(&mut self) -> Result<()>
Collect metrics and out various debugging data like per cell stats, per-cpu stats, etc.
Sourcepub(crate) fn collect_demand_metrics(
&mut self,
cpu_ctxs: &[cpu_ctx],
) -> Result<()>
pub(crate) fn collect_demand_metrics( &mut self, cpu_ctxs: &[cpu_ctx], ) -> Result<()>
Compute per-cell demand metrics (utilization, borrowed, lent) from BPF running_ns counters.
Sourcepub(crate) fn check_cpuset_changes(&mut self) -> Result<()>
pub(crate) fn check_cpuset_changes(&mut self) -> Result<()>
Check if any cell’s cpuset was modified and recompute if so.
pub(crate) fn refresh_bpf_cells(&mut self) -> Result<()>
Auto Trait Implementations§
impl<'a> Freeze for Scheduler<'a>
impl<'a> RefUnwindSafe for Scheduler<'a>
impl<'a> Send for Scheduler<'a>
impl<'a> Sync for Scheduler<'a>
impl<'a> Unpin for Scheduler<'a>
impl<'a> UnsafeUnpin for Scheduler<'a>
impl<'a> !UnwindSafe for Scheduler<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Conv for T
impl<T> Conv for T
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.