[PERF] Host Debug Overlay Isolation
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
use crate::log::{LogLevel, LogService, LogSource};
|
||||
use std::sync::atomic::{AtomicU32, AtomicU64, AtomicUsize, Ordering};
|
||||
use std::sync::Arc;
|
||||
|
||||
#[derive(Debug, Clone, Copy, Default)]
|
||||
pub struct TelemetryFrame {
|
||||
@@ -29,6 +31,69 @@ pub struct TelemetryFrame {
|
||||
pub logs_count: u32,
|
||||
}
|
||||
|
||||
/// Thread-safe, atomic telemetry storage for real-time monitoring by the host.
|
||||
/// This follows the push-based model from DEC-0005 to avoid expensive scans or locks.
|
||||
#[derive(Debug, Default)]
|
||||
pub struct AtomicTelemetry {
|
||||
pub frame_index: AtomicU64,
|
||||
pub cycles_used: AtomicU64,
|
||||
pub cycles_budget: AtomicU64,
|
||||
pub syscalls: AtomicU32,
|
||||
pub host_cpu_time_us: AtomicU64,
|
||||
pub vm_steps: AtomicU32,
|
||||
pub completed_logical_frames: AtomicU32,
|
||||
pub violations: AtomicU32,
|
||||
|
||||
// GFX Banks
|
||||
pub gfx_used_bytes: AtomicUsize,
|
||||
pub gfx_inflight_bytes: AtomicUsize,
|
||||
pub gfx_slots_occupied: AtomicU32,
|
||||
|
||||
// Audio Banks
|
||||
pub audio_used_bytes: AtomicUsize,
|
||||
pub audio_inflight_bytes: AtomicUsize,
|
||||
pub audio_slots_occupied: AtomicU32,
|
||||
|
||||
// RAM (Heap)
|
||||
pub heap_used_bytes: AtomicUsize,
|
||||
pub heap_max_bytes: AtomicUsize,
|
||||
|
||||
// Log Pressure
|
||||
pub logs_count: Arc<AtomicU32>,
|
||||
}
|
||||
|
||||
impl AtomicTelemetry {
|
||||
pub fn new(logs_count: Arc<AtomicU32>) -> Self {
|
||||
Self {
|
||||
logs_count,
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
|
||||
/// Snapshots the current atomic state into a TelemetryFrame.
|
||||
pub fn snapshot(&self) -> TelemetryFrame {
|
||||
TelemetryFrame {
|
||||
frame_index: self.frame_index.load(Ordering::Relaxed),
|
||||
cycles_used: self.cycles_used.load(Ordering::Relaxed),
|
||||
cycles_budget: self.cycles_budget.load(Ordering::Relaxed),
|
||||
syscalls: self.syscalls.load(Ordering::Relaxed),
|
||||
host_cpu_time_us: self.host_cpu_time_us.load(Ordering::Relaxed),
|
||||
completed_logical_frames: self.completed_logical_frames.load(Ordering::Relaxed),
|
||||
violations: self.violations.load(Ordering::Relaxed),
|
||||
gfx_used_bytes: self.gfx_used_bytes.load(Ordering::Relaxed),
|
||||
gfx_inflight_bytes: self.gfx_inflight_bytes.load(Ordering::Relaxed),
|
||||
gfx_slots_occupied: self.gfx_slots_occupied.load(Ordering::Relaxed),
|
||||
audio_used_bytes: self.audio_used_bytes.load(Ordering::Relaxed),
|
||||
audio_inflight_bytes: self.audio_inflight_bytes.load(Ordering::Relaxed),
|
||||
audio_slots_occupied: self.audio_slots_occupied.load(Ordering::Relaxed),
|
||||
heap_used_bytes: self.heap_used_bytes.load(Ordering::Relaxed),
|
||||
heap_max_bytes: self.heap_max_bytes.load(Ordering::Relaxed),
|
||||
logs_count: self.logs_count.load(Ordering::Relaxed),
|
||||
vm_steps: self.vm_steps.load(Ordering::Relaxed),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, Default)]
|
||||
pub struct CertificationConfig {
|
||||
pub enabled: bool,
|
||||
@@ -196,6 +261,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_certifier_violations() {
|
||||
let mut ls = LogService::new(10);
|
||||
let config = CertificationConfig {
|
||||
enabled: true,
|
||||
cycles_budget_per_frame: Some(100),
|
||||
@@ -205,7 +271,6 @@ mod tests {
|
||||
..Default::default()
|
||||
};
|
||||
let cert = Certifier::new(config);
|
||||
let mut ls = LogService::new(10);
|
||||
|
||||
let mut tel = TelemetryFrame::default();
|
||||
tel.cycles_used = 150;
|
||||
|
||||
Reference in New Issue
Block a user