Skip to main content

LoadBalancer

Struct LoadBalancer 

Source
pub struct LoadBalancer { /* private fields */ }
Expand description

Load balancer for distributing work across GPUs

Implementations§

Source§

impl LoadBalancer

Source

pub fn new(devices: Vec<Arc<GpuDevice>>, strategy: SelectionStrategy) -> Self

Create a new load balancer

Source

pub fn migration_config(&self) -> MigrationConfig

Get the migration configuration

Source

pub fn set_migration_config(&self, config: MigrationConfig)

Update migration configuration

Source

pub fn select_device(&self) -> Result<Arc<GpuDevice>>

Select a device using the configured strategy

Source

pub fn select_weighted(&self) -> Result<Arc<GpuDevice>>

Select device using weighted strategy based on device performance

Source

pub fn get_device_loads(&self) -> Vec<DeviceLoad>

Get current load information for all devices

Source

pub fn identify_overloaded_devices(&self) -> Vec<DeviceLoad>

Identify overloaded devices

Source

pub fn identify_underutilized_devices(&self) -> Vec<DeviceLoad>

Identify underutilized devices

Source

pub fn is_imbalanced(&self) -> bool

Check if load is imbalanced (requires rebalancing)

Source

pub fn calculate_transfer_cost( &self, source_device: usize, target_device: usize, data_size: u64, ) -> Result<f64>

Calculate data transfer cost between two devices

Source

pub fn create_migration_plan( &self, workload: MigratableWorkload, target_device: usize, ) -> Result<MigrationPlan>

Create a migration plan for a workload

Source

pub fn find_migration_target( &self, source_device: usize, ) -> Result<Option<usize>>

Find best migration target for an overloaded device

Source

pub fn select_workload_for_migration( &self, source_device: usize, ) -> Option<MigratableWorkload>

Select workload to migrate from an overloaded device

Source

pub fn execute_migration(&self, plan: &MigrationPlan) -> Result<MigrationResult>

Execute a migration (simulated - actual data transfer would use sync module)

Source

pub fn rebalance(&self) -> Result<Vec<MigrationResult>>

Rebalance workloads across devices

This method implements the core workload migration logic:

  1. Monitor GPU utilization across all devices
  2. Identify overloaded and underutilized GPUs
  3. Calculate transfer costs for potential migrations
  4. Execute migrations that improve overall balance
Source

pub fn register_workload( &self, device_index: usize, memory_size: u64, compute_intensity: f32, priority: u32, ) -> Result<u64>

Register a new workload on a device

Source

pub fn unregister_workload( &self, device_index: usize, workload_id: u64, ) -> Result<()>

Unregister a workload (completed or cancelled)

Source

pub fn task_started(&self, device_index: usize)

Mark task started on device

Source

pub fn task_completed(&self, device_index: usize, duration_us: u64)

Mark task completed on device

Source

pub fn get_stats(&self) -> LoadStats

Get load statistics

Source

pub fn print_stats(&self)

Print load statistics

Source

pub fn reset_stats(&self)

Reset statistics

Source

pub fn get_device_utilization(&self, device_index: usize) -> f32

Get device utilization (0.0 to 1.0)

Source

pub fn get_cluster_utilization(&self) -> f32

Get overall cluster utilization (0.0 to 1.0)

Source

pub fn suggest_device(&self, estimated_memory: u64) -> Result<Arc<GpuDevice>>

Suggest optimal device for next task

Source

pub fn get_migration_stats(&self) -> (usize, usize, f64)

Get migration history statistics

Source

pub fn device_count(&self) -> usize

Get device count

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,