|
Thread System 0.3.1
High-performance C++20 thread pool with work stealing and DAG scheduling
|
Statistics for work-stealing operations. More...
#include <work_stealing_stats.h>

Public Member Functions | |
| auto | steal_success_rate () const -> double |
| Calculate the steal success rate. | |
| auto | avg_batch_size () const -> double |
| Calculate the average batch size. | |
| auto | cross_node_ratio () const -> double |
| Calculate the cross-NUMA node steal ratio. | |
| auto | avg_steal_time_ns () const -> double |
| Calculate average steal operation time. | |
| void | reset () |
| Reset all statistics to zero. | |
| auto | snapshot () const -> work_stealing_stats_snapshot |
| Create a snapshot of current statistics. | |
Public Attributes | |
| std::atomic< std::uint64_t > | steal_attempts {0} |
| Total number of steal attempts. | |
| std::atomic< std::uint64_t > | successful_steals {0} |
| Number of successful steal operations. | |
| std::atomic< std::uint64_t > | failed_steals {0} |
| Number of failed steal operations. | |
| std::atomic< std::uint64_t > | jobs_stolen {0} |
| Total number of jobs successfully stolen. | |
| std::atomic< std::uint64_t > | same_node_steals {0} |
| Steals from workers on the same NUMA node. | |
| std::atomic< std::uint64_t > | cross_node_steals {0} |
| Steals from workers on different NUMA nodes. | |
| std::atomic< std::uint64_t > | batch_steals {0} |
| Number of batch steal operations (stealing multiple jobs) | |
| std::atomic< std::uint64_t > | total_batch_size {0} |
| Total size of all batch steals (for averaging) | |
| std::atomic< std::uint64_t > | total_steal_time_ns {0} |
| Total time spent in steal operations (nanoseconds) | |
| std::atomic< std::uint64_t > | total_backoff_time_ns {0} |
| Total time spent in backoff delays (nanoseconds) | |
Statistics for work-stealing operations.
This structure tracks various metrics about work-stealing performance, including success rates, NUMA locality, batch efficiency, and timing. All counters are atomic for thread-safe updates from multiple workers.
All members use atomic operations for lock-free concurrent updates. Statistics may show momentary inconsistencies during rapid updates but will eventually converge to accurate totals.
Definition at line 110 of file work_stealing_stats.h.
|
inlinenodiscard |
Calculate the average batch size.
Returns 0.0 if no batch steals have been made.
Definition at line 185 of file work_stealing_stats.h.
References batch_steals, and total_batch_size.
|
inlinenodiscard |
Calculate average steal operation time.
Returns 0.0 if no steal attempts have been made.
Definition at line 221 of file work_stealing_stats.h.
References steal_attempts, and total_steal_time_ns.
|
inlinenodiscard |
Calculate the cross-NUMA node steal ratio.
Returns 0.0 if no successful steals have been made. Lower values indicate better NUMA locality.
Definition at line 203 of file work_stealing_stats.h.
References cross_node_steals, and same_node_steals.
|
inline |
Reset all statistics to zero.
Thread Safety: This operation is not atomic across all counters. During reset, some counters may be zero while others retain old values. For accurate snapshots during operation, avoid calling reset() while steal operations are in progress.
Definition at line 241 of file work_stealing_stats.h.
References batch_steals, cross_node_steals, failed_steals, jobs_stolen, same_node_steals, steal_attempts, successful_steals, total_backoff_time_ns, total_batch_size, and total_steal_time_ns.
Referenced by kcenon::thread::numa_work_stealer::reset_stats().

|
inlinenodiscard |
Create a snapshot of current statistics.
This creates a non-atomic snapshot that can be safely read without worrying about concurrent updates.
Definition at line 262 of file work_stealing_stats.h.
References batch_steals, kcenon::thread::work_stealing_stats_snapshot::batch_steals, cross_node_steals, kcenon::thread::work_stealing_stats_snapshot::cross_node_steals, failed_steals, kcenon::thread::work_stealing_stats_snapshot::failed_steals, jobs_stolen, kcenon::thread::work_stealing_stats_snapshot::jobs_stolen, same_node_steals, kcenon::thread::work_stealing_stats_snapshot::same_node_steals, steal_attempts, kcenon::thread::work_stealing_stats_snapshot::steal_attempts, successful_steals, kcenon::thread::work_stealing_stats_snapshot::successful_steals, total_backoff_time_ns, kcenon::thread::work_stealing_stats_snapshot::total_backoff_time_ns, total_batch_size, kcenon::thread::work_stealing_stats_snapshot::total_batch_size, total_steal_time_ns, and kcenon::thread::work_stealing_stats_snapshot::total_steal_time_ns.
Referenced by kcenon::thread::numa_work_stealer::get_stats_snapshot().

|
inlinenodiscard |
Calculate the steal success rate.
Returns 0.0 if no steal attempts have been made.
Definition at line 168 of file work_stealing_stats.h.
References steal_attempts, and successful_steals.
| std::atomic<std::uint64_t> kcenon::thread::work_stealing_stats::batch_steals {0} |
Number of batch steal operations (stealing multiple jobs)
Definition at line 143 of file work_stealing_stats.h.
Referenced by avg_batch_size(), reset(), and snapshot().
| std::atomic<std::uint64_t> kcenon::thread::work_stealing_stats::cross_node_steals {0} |
Steals from workers on different NUMA nodes.
Definition at line 136 of file work_stealing_stats.h.
Referenced by cross_node_ratio(), reset(), and snapshot().
| std::atomic<std::uint64_t> kcenon::thread::work_stealing_stats::failed_steals {0} |
Number of failed steal operations.
Definition at line 123 of file work_stealing_stats.h.
Referenced by reset(), and snapshot().
| std::atomic<std::uint64_t> kcenon::thread::work_stealing_stats::jobs_stolen {0} |
Total number of jobs successfully stolen.
Definition at line 126 of file work_stealing_stats.h.
Referenced by reset(), and snapshot().
| std::atomic<std::uint64_t> kcenon::thread::work_stealing_stats::same_node_steals {0} |
Steals from workers on the same NUMA node.
Definition at line 133 of file work_stealing_stats.h.
Referenced by cross_node_ratio(), reset(), and snapshot().
| std::atomic<std::uint64_t> kcenon::thread::work_stealing_stats::steal_attempts {0} |
Total number of steal attempts.
Definition at line 117 of file work_stealing_stats.h.
Referenced by avg_steal_time_ns(), reset(), snapshot(), and steal_success_rate().
| std::atomic<std::uint64_t> kcenon::thread::work_stealing_stats::successful_steals {0} |
Number of successful steal operations.
Definition at line 120 of file work_stealing_stats.h.
Referenced by reset(), snapshot(), and steal_success_rate().
| std::atomic<std::uint64_t> kcenon::thread::work_stealing_stats::total_backoff_time_ns {0} |
Total time spent in backoff delays (nanoseconds)
Definition at line 156 of file work_stealing_stats.h.
Referenced by reset(), and snapshot().
| std::atomic<std::uint64_t> kcenon::thread::work_stealing_stats::total_batch_size {0} |
Total size of all batch steals (for averaging)
Definition at line 146 of file work_stealing_stats.h.
Referenced by avg_batch_size(), reset(), and snapshot().
| std::atomic<std::uint64_t> kcenon::thread::work_stealing_stats::total_steal_time_ns {0} |
Total time spent in steal operations (nanoseconds)
Definition at line 153 of file work_stealing_stats.h.
Referenced by avg_steal_time_ns(), reset(), and snapshot().