Skip to content

Enforce common_system dependency and add runtime metrics #129

Description

@kcenon

Summary

This PR strengthens thread_system's foundation by enforcing common_system dependency and adding comprehensive runtime metrics:

  1. Required Dependency on common_system

    • Enforce common_system availability at CMake configuration time
    • Ensure IExecutor interface compatibility
    • Align with unified build system architecture
  2. Runtime Performance Metrics

    • Thread pool metrics collection and tracking
    • Job lifecycle monitoring (submission, completion, rejection)
    • Queue depth and worker utilization metrics

Changes

Build System

  • Add fatal error when common_system is not available
  • Update ThreadSystemDependencies.cmake for proper detection
  • Ensure unified build integration

Metrics Infrastructure

  • New ThreadPoolMetrics class with atomic counters
  • Track job counts, queue depth, worker activity
  • Provide read-only access and reset functionality

Thread Pool Integration

  • Add metrics() accessor to ThreadPool
  • Integrate metrics collection in job submission path
  • Update workers to record completion events
  • Maintain zero-overhead when metrics not accessed

API Changes

New Public Methods

const metrics::ThreadPoolMetrics& thread_pool::metrics() const noexcept;
void thread_pool::reset_metrics();

Breaking Changes

  • thread_system now REQUIRES common_system
  • Projects must link against common_system

Testing

  • Builds with common_system dependency
  • Metrics accumulate correctly
  • Reset functionality works
  • No performance regression

Migration Guide

For standalone builds:

set(BUILD_WITH_COMMON_SYSTEM ON)
find_package(common_system REQUIRED)
target_link_libraries(your_target PRIVATE thread_system)

Performance Impact

  • Metrics use atomic operations (minimal overhead)
  • No impact when metrics not accessed
  • Reset operation is O(1)

Linked PR: #92 Enforce common_system dependency and add runtime metrics

Metadata

Metadata

Assignees

Labels

buildBuild system and configurationci-cdCI/CD and build automationdependenciesExternal dependencies managementenhancementNew feature or requestperformancePerformance improvementstestingTesting related issuesthreadingThreading and concurrency

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions