Skip to content

[REFACTOR] Consolidate buffering layer - C++20 Module preparation #309

Description

@kcenon

Summary

Consolidate multiple buffering implementations in monitoring_system to simplify the codebase for C++20 module migration, following Kent Beck's "Fewest Elements" principle.

Parent Epic

Part of kcenon/common_system#256 (C++20 Module Migration - Cross-System Preparation)

Current State

Buffer Implementation Inventory

File Class Purpose Status
core/thread_local_buffer.h Thread-local buffer Per-thread metric buffering ✓ Keep (public API)
utils/time_series_buffer.h Time series buffer Temporal metric storage Refactor needed
utils/time_series_buffer.h load_average_history Load average storage Consolidate with above
utils/buffer_manager.h Buffer manager Buffer lifecycle management ✓ Keep (internal)
utils/buffering_strategy.h Buffering strategy Strategy pattern for buffering Refactor needed
utils/ring_buffer.h Ring buffer Circular buffer implementation ✓ Keep (internal)

Analysis Results

Identified Issues

Issue Kent Beck Principle Action
load_average_history duplicates time_series_buffer<T> No Duplication Consolidate
buffering_strategy imports but doesn't use ring_buffer Fewest Elements Refactor
Unclear public vs internal API Reveals Intention Document

C++20 Module Impact

Clear separation between public and internal APIs needed for:

export module kcenon.monitoring;
export import :core;       // thread_local_buffer, central_collector
export import :buffers;    // time_series_buffer (public)
// Internal: ring_buffer, buffering_strategy, buffer_manager

Sub-Issues

Tasks

  • Review thread_local_buffer usage and necessity → Keep (used by central_collector)
  • Review time_series_buffer usage and necessity → Keep (used by system_resource_collector)
  • Review buffer_manager and buffering_strategy overlap → Keep both (different purposes)
  • Identify unused or redundant buffer implementations → load_average_history is redundant
  • Create consolidation plan → Sub-issues created
  • Implement changes with deprecation warnings
  • Update documentation

Acceptance Criteria

  • Clear separation between public and internal buffer APIs
  • No redundant buffer implementations
  • Unified buffering interface where applicable
  • All tests pass
  • No breaking changes to public API

Related

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions