Thread System 0.3.1
High-performance C++20 thread pool with work stealing and DAG scheduling
Loading...
Searching...
No Matches
kcenon::thread::work_stealing_stats_snapshot Struct Reference

Non-atomic snapshot of work-stealing statistics. More...

#include <work_stealing_stats.h>

Collaboration diagram for kcenon::thread::work_stealing_stats_snapshot:
Collaboration graph

Public Member Functions

auto steal_success_rate () const -> double
 
auto avg_batch_size () const -> double
 
auto cross_node_ratio () const -> double
 
auto avg_steal_time_ns () const -> double
 

Public Attributes

std::uint64_t steal_attempts {0}
 
std::uint64_t successful_steals {0}
 
std::uint64_t failed_steals {0}
 
std::uint64_t jobs_stolen {0}
 
std::uint64_t same_node_steals {0}
 
std::uint64_t cross_node_steals {0}
 
std::uint64_t batch_steals {0}
 
std::uint64_t total_batch_size {0}
 
std::uint64_t total_steal_time_ns {0}
 
std::uint64_t total_backoff_time_ns {0}
 

Detailed Description

Non-atomic snapshot of work-stealing statistics.

This structure provides a non-atomic copy of work_stealing_stats for safe reading without synchronization concerns.

Definition at line 27 of file work_stealing_stats.h.

Member Function Documentation

◆ avg_batch_size()

auto kcenon::thread::work_stealing_stats_snapshot::avg_batch_size ( ) const -> double
inlinenodiscard

Definition at line 49 of file work_stealing_stats.h.

50 {
51 if (batch_steals == 0)
52 {
53 return 0.0;
54 }
55 return static_cast<double>(total_batch_size) / static_cast<double>(batch_steals);
56 }

References batch_steals, and total_batch_size.

◆ avg_steal_time_ns()

auto kcenon::thread::work_stealing_stats_snapshot::avg_steal_time_ns ( ) const -> double
inlinenodiscard

Definition at line 68 of file work_stealing_stats.h.

69 {
70 if (steal_attempts == 0)
71 {
72 return 0.0;
73 }
74 return static_cast<double>(total_steal_time_ns) / static_cast<double>(steal_attempts);
75 }

References steal_attempts, and total_steal_time_ns.

◆ cross_node_ratio()

auto kcenon::thread::work_stealing_stats_snapshot::cross_node_ratio ( ) const -> double
inlinenodiscard

Definition at line 58 of file work_stealing_stats.h.

59 {
61 if (total == 0)
62 {
63 return 0.0;
64 }
65 return static_cast<double>(cross_node_steals) / static_cast<double>(total);
66 }

References cross_node_steals, and same_node_steals.

◆ steal_success_rate()

auto kcenon::thread::work_stealing_stats_snapshot::steal_success_rate ( ) const -> double
inlinenodiscard

Definition at line 40 of file work_stealing_stats.h.

41 {
42 if (steal_attempts == 0)
43 {
44 return 0.0;
45 }
46 return static_cast<double>(successful_steals) / static_cast<double>(steal_attempts);
47 }

References steal_attempts, and successful_steals.

Member Data Documentation

◆ batch_steals

std::uint64_t kcenon::thread::work_stealing_stats_snapshot::batch_steals {0}

Definition at line 35 of file work_stealing_stats.h.

35{0};

Referenced by avg_batch_size(), and kcenon::thread::work_stealing_stats::snapshot().

◆ cross_node_steals

std::uint64_t kcenon::thread::work_stealing_stats_snapshot::cross_node_steals {0}

Definition at line 34 of file work_stealing_stats.h.

34{0};

Referenced by cross_node_ratio(), and kcenon::thread::work_stealing_stats::snapshot().

◆ failed_steals

std::uint64_t kcenon::thread::work_stealing_stats_snapshot::failed_steals {0}

Definition at line 31 of file work_stealing_stats.h.

31{0};

Referenced by kcenon::thread::work_stealing_stats::snapshot().

◆ jobs_stolen

std::uint64_t kcenon::thread::work_stealing_stats_snapshot::jobs_stolen {0}

Definition at line 32 of file work_stealing_stats.h.

32{0};

Referenced by kcenon::thread::work_stealing_stats::snapshot().

◆ same_node_steals

std::uint64_t kcenon::thread::work_stealing_stats_snapshot::same_node_steals {0}

Definition at line 33 of file work_stealing_stats.h.

33{0};

Referenced by cross_node_ratio(), and kcenon::thread::work_stealing_stats::snapshot().

◆ steal_attempts

std::uint64_t kcenon::thread::work_stealing_stats_snapshot::steal_attempts {0}

◆ successful_steals

std::uint64_t kcenon::thread::work_stealing_stats_snapshot::successful_steals {0}

Definition at line 30 of file work_stealing_stats.h.

30{0};

Referenced by kcenon::thread::work_stealing_stats::snapshot(), and steal_success_rate().

◆ total_backoff_time_ns

std::uint64_t kcenon::thread::work_stealing_stats_snapshot::total_backoff_time_ns {0}

Definition at line 38 of file work_stealing_stats.h.

38{0};

Referenced by kcenon::thread::work_stealing_stats::snapshot().

◆ total_batch_size

std::uint64_t kcenon::thread::work_stealing_stats_snapshot::total_batch_size {0}

Definition at line 36 of file work_stealing_stats.h.

36{0};

Referenced by avg_batch_size(), and kcenon::thread::work_stealing_stats::snapshot().

◆ total_steal_time_ns

std::uint64_t kcenon::thread::work_stealing_stats_snapshot::total_steal_time_ns {0}

Definition at line 37 of file work_stealing_stats.h.

37{0};

Referenced by avg_steal_time_ns(), and kcenon::thread::work_stealing_stats::snapshot().


The documentation for this struct was generated from the following file: