euv-performance 0.48.0

Reproducible CPU, layout, rasterization, and allocation benchmarks for the cross-platform euv runtime.
Documentation
use super::*;

/// Zero-sized global allocator delegating directly to `System` with a single-load disabled fast path.
#[derive(Clone, Copy, Debug, Default)]
pub struct CountingAllocator;

/// Snapshot of raw monotonic allocation counters captured at a scope boundary.
#[derive(Clone, Copy, Debug, Default, Eq, Getter, New, PartialEq)]
pub struct RawAllocCounters {
    /// Cumulative allocation count at snapshot time.
    #[get(type(copy))]
    pub(crate) alloc_count: u64,
    /// Cumulative deallocation count at snapshot time.
    #[get(type(copy))]
    pub(crate) free_count: u64,
    /// Cumulative bytes allocated at snapshot time.
    #[get(type(copy))]
    pub(crate) bytes_allocated: u64,
    /// Cumulative bytes freed at snapshot time.
    #[get(type(copy))]
    pub(crate) bytes_freed: u64,
    /// Signed net live bytes delta at snapshot time.
    #[get(type(copy))]
    pub(crate) live_bytes_delta: i64,
    /// Signed net live allocation count delta at snapshot time.
    #[get(type(copy))]
    pub(crate) live_allocs_delta: i64,
    /// Peak positive live bytes delta recorded in the enclosing scope.
    #[get(type(copy))]
    pub(crate) peak_live_bytes: u64,
}

/// Exact heap allocation delta recorded across a measured steady-state frame or workload scope.
#[derive(Clone, Copy, Debug, Default, Deserialize, Eq, Getter, New, PartialEq, Serialize)]
pub struct AllocationSnapshot {
    /// Total heap allocation calls (`alloc`, `alloc_zeroed`, `realloc`) in the measured scope.
    #[get(type(copy))]
    pub(crate) alloc_count: u64,
    /// Total heap deallocation calls (`dealloc`, `realloc`) in the measured scope.
    #[get(type(copy))]
    pub(crate) free_count: u64,
    /// Total heap bytes allocated in the measured scope.
    #[get(type(copy))]
    pub(crate) bytes_allocated: u64,
    /// Total heap bytes freed in the measured scope.
    #[get(type(copy))]
    pub(crate) bytes_freed: u64,
    /// Net retained live bytes delta clamped at zero at scope exit.
    #[get(type(copy))]
    pub(crate) live_bytes_delta: u64,
    /// Net retained live allocation delta clamped at zero at scope exit.
    #[get(type(copy))]
    pub(crate) live_allocs_delta: u64,
    /// Peak positive live bytes observed during the measured scope.
    #[get(type(copy))]
    pub(crate) peak_live_bytes: u64,
}

/// RAII scope guard enabling `CountingAllocator` tracking for the lifetime of a benchmark loop.
#[derive(Debug)]
pub struct AllocationScopeGuard {
    /// Mutex guard held by the outermost active scope on this thread.
    pub(crate) _lock_guard: Option<MutexGuard<'static, ()>>,
    /// Whether this guard owns the outermost scope entry on the current thread.
    pub(crate) owns_scope: bool,
    /// Raw counter baseline captured immediately after enabling tracking.
    pub(crate) start_counters: RawAllocCounters,
}

/// Multi-cycle native heap lifecycle probe capturing baseline, post-drain live bytes, and per-cycle slope.
#[derive(Clone, Copy, Debug, Default, Deserialize, Getter, PartialEq, Serialize)]
pub struct NativeHeapLifecycleProbe {
    /// Number of mount/step/dispose lifecycle drain cycles executed after warmup.
    #[get(type(copy))]
    pub(crate) cycles: u64,
    /// Post-warmup live heap bytes baseline in bytes.
    #[get(type(copy))]
    pub(crate) baseline_live_bytes: u64,
    /// Post-drain live heap bytes after all lifecycle cycles complete.
    #[get(type(copy))]
    pub(crate) after_drain_live_bytes: u64,
    /// Linear slope of live heap bytes per lifecycle cycle.
    #[get(type(copy))]
    pub(crate) live_bytes_slope_per_cycle: f64,
    /// Post-warmup live allocation count baseline.
    #[get(type(copy))]
    pub(crate) baseline_live_allocations: u64,
    /// Post-drain live allocation count after all lifecycle cycles complete.
    #[get(type(copy))]
    pub(crate) after_drain_live_allocations: u64,
    /// Linear slope of live allocations per lifecycle cycle.
    #[get(type(copy))]
    pub(crate) live_allocations_slope_per_cycle: f64,
    /// Peak positive live heap bytes observed during the lifecycle probe.
    #[get(type(copy))]
    pub(crate) peak_live_bytes: u64,
    /// Total heap allocations recorded across the measured lifecycle cycles.
    #[get(type(copy))]
    pub(crate) total_alloc_count: u64,
    /// Total heap frees recorded across the measured lifecycle cycles.
    #[get(type(copy))]
    pub(crate) total_free_count: u64,
    /// Total heap bytes allocated across the measured lifecycle cycles.
    #[get(type(copy))]
    pub(crate) total_bytes_allocated: u64,
}