58 default:
return "unknown";
222 case 0:
return "none";
223 case 1:
return "low";
224 case 2:
return "medium";
225 case 3:
return "critical";
226 default:
return "unknown";
267 std::ostringstream oss;
269 oss <<
" \"has_bottleneck\": " << (
has_bottleneck ?
"true" :
"false") <<
",\n";
272 oss <<
" \"description\": \"" <<
description <<
"\",\n";
275 oss <<
" \"metrics\": {\n";
276 oss << std::fixed << std::setprecision(4);
278 oss << std::setprecision(3);
280 oss << std::setprecision(4);
284 oss <<
" \"queue_depth\": " <<
queue_depth <<
",\n";
291 oss <<
" \"recommendations\": [";
335 std::ostringstream oss;
337 oss <<
"=== Bottleneck Report ===\n";
346 oss <<
"Status: No bottleneck detected\n\n";
358 oss <<
" Wait time: " << std::setprecision(3) <<
avg_wait_time_ms <<
"ms avg\n";
369 oss <<
"\nRecommendations:\n";
372 oss <<
" - " << rec <<
"\n";
bottleneck_type
Type of bottleneck detected in the thread pool.
@ slow_consumer
Workers can't keep up with job submission rate.
@ lock_contention
High mutex wait times affecting throughput.
@ worker_starvation
Not enough workers for the workload.
@ none
No bottleneck detected.
@ queue_full
Queue is at capacity.
@ memory_pressure
Excessive memory allocations causing slowdown.
@ uneven_distribution
Work is not evenly distributed (work stealing needed)
auto bottleneck_type_to_string(bottleneck_type type) -> std::string
Converts bottleneck_type to human-readable string.
Analysis report of bottlenecks in the thread pool.
bottleneck_type type
Type of bottleneck detected.
double avg_wait_time_ms
Average wait time in milliseconds.
std::vector< std::string > recommendations
Actionable recommendations to resolve the bottleneck.
std::string description
Human-readable description of the bottleneck.
double utilization_variance
Variance in worker utilization.
auto to_string() const -> std::string
Converts the bottleneck report to a human-readable string.
auto requires_immediate_action() const -> bool
Checks if immediate action is required.
bool has_bottleneck
Whether a bottleneck was detected.
std::uint64_t jobs_rejected
Jobs rejected due to queue full.
std::size_t estimated_backlog_time_ms
Estimated time to process the current backlog.
std::size_t queue_depth
Current queue depth.
double queue_saturation
Queue saturation level.
auto severity() const -> int
Gets the severity level of the bottleneck.
std::size_t idle_workers
Number of idle workers.
auto severity_string() const -> std::string
Gets severity as a string.
std::size_t total_workers
Total number of workers.
auto to_json() const -> std::string
Converts the bottleneck report to a JSON string.
double worker_utilization
Average worker utilization.