pub struct GpuMemoryDashboard {
allocations: RwLock<HashMap<u64, GpuMemoryAllocation>>,
device_stats: RwLock<HashMap<u32, GpuDeviceMemoryStats>>,
thresholds: GpuMemoryThresholds,
allocation_counter: AtomicU64,
total_allocated: AtomicU64,
peak_allocated: AtomicU64,
}Expand description
GPU Memory Dashboard for monitoring and visualization.
Provides real-time GPU memory tracking with allocation history, per-kernel usage, and memory pressure alerts.
§Example
use ringkernel_core::observability::GpuMemoryDashboard;
let dashboard = GpuMemoryDashboard::new();
// Track an allocation
dashboard.track_allocation(
1,
"input_queue",
65536,
GpuMemoryType::QueueBuffer,
0,
Some("processor_kernel"),
);
// Get current stats
let stats = dashboard.get_device_stats(0);
println!("GPU 0 utilization: {:.1}%", stats.utilization());
// Generate Grafana panel JSON
let panel = dashboard.grafana_panel();Fields§
§allocations: RwLock<HashMap<u64, GpuMemoryAllocation>>Active allocations.
device_stats: RwLock<HashMap<u32, GpuDeviceMemoryStats>>Per-device statistics.
thresholds: GpuMemoryThresholdsMemory pressure thresholds.
allocation_counter: AtomicU64Allocation counter for unique IDs.
total_allocated: AtomicU64Total bytes allocated.
peak_allocated: AtomicU64Peak bytes allocated.
Implementations§
Source§impl GpuMemoryDashboard
impl GpuMemoryDashboard
Sourcepub fn with_thresholds(thresholds: GpuMemoryThresholds) -> Arc<Self>
pub fn with_thresholds(thresholds: GpuMemoryThresholds) -> Arc<Self>
Create with custom thresholds.
Sourcepub fn track_allocation(
&self,
id: u64,
name: impl Into<String>,
size: usize,
memory_type: GpuMemoryType,
device_index: u32,
kernel_id: Option<&str>,
)
pub fn track_allocation( &self, id: u64, name: impl Into<String>, size: usize, memory_type: GpuMemoryType, device_index: u32, kernel_id: Option<&str>, )
Track a new GPU memory allocation.
Sourcepub fn next_allocation_id(&self) -> u64
pub fn next_allocation_id(&self) -> u64
Generate a new unique allocation ID.
Sourcepub fn track_deallocation(&self, id: u64)
pub fn track_deallocation(&self, id: u64)
Track deallocation.
Sourcepub fn mark_unused(&self, id: u64)
pub fn mark_unused(&self, id: u64)
Mark an allocation as no longer in use (but not freed).
Sourcepub fn register_device(
&self,
device_index: u32,
name: impl Into<String>,
total_memory: u64,
)
pub fn register_device( &self, device_index: u32, name: impl Into<String>, total_memory: u64, )
Register a GPU device.
Sourcepub fn update_device_stats(
&self,
device_index: u32,
free_memory: u64,
ringkernel_used: u64,
)
pub fn update_device_stats( &self, device_index: u32, free_memory: u64, ringkernel_used: u64, )
Update device memory statistics.
Sourcepub fn get_device_stats(
&self,
device_index: u32,
) -> Option<GpuDeviceMemoryStats>
pub fn get_device_stats( &self, device_index: u32, ) -> Option<GpuDeviceMemoryStats>
Get device statistics.
Sourcepub fn get_all_device_stats(&self) -> Vec<GpuDeviceMemoryStats>
pub fn get_all_device_stats(&self) -> Vec<GpuDeviceMemoryStats>
Get all device statistics.
Sourcepub fn get_allocations(&self) -> Vec<GpuMemoryAllocation>
pub fn get_allocations(&self) -> Vec<GpuMemoryAllocation>
Get all active allocations.
Sourcepub fn get_kernel_allocations(
&self,
kernel_id: &str,
) -> Vec<GpuMemoryAllocation>
pub fn get_kernel_allocations( &self, kernel_id: &str, ) -> Vec<GpuMemoryAllocation>
Get allocations for a specific kernel.
Sourcepub fn total_allocated(&self) -> u64
pub fn total_allocated(&self) -> u64
Get total allocated memory.
Sourcepub fn peak_allocated(&self) -> u64
pub fn peak_allocated(&self) -> u64
Get peak allocated memory.
Sourcepub fn allocation_count(&self) -> usize
pub fn allocation_count(&self) -> usize
Get allocation count.
Sourcepub fn check_pressure(&self, device_index: u32) -> MemoryPressureLevel
pub fn check_pressure(&self, device_index: u32) -> MemoryPressureLevel
Check memory pressure level for a device.
Sourcepub fn grafana_panel(&self) -> GrafanaPanel
pub fn grafana_panel(&self) -> GrafanaPanel
Generate Grafana dashboard panel for GPU memory.
Sourcepub fn prometheus_metrics(&self) -> String
pub fn prometheus_metrics(&self) -> String
Generate Prometheus metrics for GPU memory.
Sourcepub fn summary_report(&self) -> String
pub fn summary_report(&self) -> String
Generate a memory summary report.