implement PLN-0034 internal allocation evidence
This commit is contained in:
@@ -22,6 +22,6 @@ impl<'a> HostReturn<'a> {
|
||||
self.stack.push(Value::HeapRef(HeapRef(g as u32)));
|
||||
}
|
||||
pub fn push_string(&mut self, s: String) {
|
||||
self.stack.push(Value::String(s.into()));
|
||||
self.stack.push(Value::string(s));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,8 @@ pub struct TelemetryFrame {
|
||||
// RAM (Heap)
|
||||
pub heap_used_bytes: usize,
|
||||
pub heap_max_bytes: usize,
|
||||
pub vm_heap_allocations: u64,
|
||||
pub vm_string_materializations: u64,
|
||||
|
||||
// Log Pressure from the last completed logical frame
|
||||
pub logs_count: u32,
|
||||
@@ -53,6 +55,8 @@ pub struct AtomicTelemetry {
|
||||
// RAM (Heap)
|
||||
pub heap_used_bytes: AtomicUsize,
|
||||
pub heap_max_bytes: AtomicUsize,
|
||||
pub vm_heap_allocations: AtomicU64,
|
||||
pub vm_string_materializations: AtomicU64,
|
||||
|
||||
// Transient in-flight log counter for the current logical frame
|
||||
pub current_logs_count: Arc<AtomicU32>,
|
||||
@@ -83,6 +87,8 @@ impl AtomicTelemetry {
|
||||
scene_slots_total: self.scene_slots_total.load(Ordering::Relaxed),
|
||||
heap_used_bytes: self.heap_used_bytes.load(Ordering::Relaxed),
|
||||
heap_max_bytes: self.heap_max_bytes.load(Ordering::Relaxed),
|
||||
vm_heap_allocations: self.vm_heap_allocations.load(Ordering::Relaxed),
|
||||
vm_string_materializations: self.vm_string_materializations.load(Ordering::Relaxed),
|
||||
logs_count: self.logs_count.load(Ordering::Relaxed),
|
||||
vm_steps: self.vm_steps.load(Ordering::Relaxed),
|
||||
}
|
||||
@@ -102,6 +108,8 @@ impl AtomicTelemetry {
|
||||
self.scene_slots_used.store(0, Ordering::Relaxed);
|
||||
self.scene_slots_total.store(0, Ordering::Relaxed);
|
||||
self.heap_used_bytes.store(0, Ordering::Relaxed);
|
||||
self.vm_heap_allocations.store(0, Ordering::Relaxed);
|
||||
self.vm_string_materializations.store(0, Ordering::Relaxed);
|
||||
self.vm_steps.store(0, Ordering::Relaxed);
|
||||
self.logs_count.store(0, Ordering::Relaxed);
|
||||
self.current_logs_count.store(0, Ordering::Relaxed);
|
||||
@@ -313,4 +321,17 @@ mod tests {
|
||||
assert_eq!(snapshot.logs_count, 3);
|
||||
assert_eq!(current.load(Ordering::Relaxed), 7);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn snapshot_includes_internal_allocation_evidence() {
|
||||
let current = Arc::new(AtomicU32::new(0));
|
||||
let tel = AtomicTelemetry::new(current);
|
||||
tel.vm_heap_allocations.store(2, Ordering::Relaxed);
|
||||
tel.vm_string_materializations.store(5, Ordering::Relaxed);
|
||||
|
||||
let snapshot = tel.snapshot();
|
||||
|
||||
assert_eq!(snapshot.vm_heap_allocations, 2);
|
||||
assert_eq!(snapshot.vm_string_materializations, 5);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user