Skip to content

Add memory-efficient historical tracking with ring buffers #65

@lowhung

Description

@lowhung

Summary

Implement bounded historical tracking with smart retention for trend analysis without unbounded memory growth.

Proposed Implementation

struct RollingMetricsBuffer {
    // Ring buffer for fixed memory usage
    samples: VecDeque<MetricsSample>,
    max_samples: usize,        // e.g., 3600 for 1-hour at 1Hz
    compress_older_than: Duration,  // compress samples older than 1 hour
    
    compression_ratio: usize,  // aggregate every N old samples
}

Features

  • Configurable ring buffer size (trades memory for history length)
  • Automatic downsampling of old data (average every N samples)
  • Memory alerts if buffer approaching limits
  • Option to offload to disk for long-term storage
  • Configurable retention policies

Benefits

  • Predictable memory usage
  • Long-term trend analysis
  • No memory leaks from unbounded growth

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions