signals
Derives heuristic PoolSignals from these metrics using thresholds.
PoolSignal.StarvationSuspected:
pending > 0and the queue-delay p95 is at or above SignalThresholds.starvationQueueDelayP95.PoolSignal.LongRunningSegment: DispatcherMetrics.longestRun is at or above SignalThresholds.longRunningSegment. On a CPU-bound dispatcher a long segment suggests a blocking call; see
DISPATCH_001andDISPATCH_002indocs/BEST_PRACTICES_COROUTINES.md.
These are heuristics, not proof. The queue-delay p95 is a histogram bucket upper bound (up to 2x the real value), and queue delay is only recorded when a block STARTS. If every worker is blocked and nothing starts, the p95 stays at its old value and PoolSignal.StarvationSuspected may not fire; the trend signals (PoolSignal.BacklogGrowing, PoolSignal.PoolSaturated) from List<TraceEvent.PoolSample>.signals do catch that case. This function only looks at one snapshot; to detect trends over time use List<TraceEvent.PoolSample>.signals, fed by PoolSampler.
Example:
stats.metrics().flatMap { it.signals() }.forEach(::println)Requires opting in to ExperimentalStructuredCoroutines.
Receiver
the metrics snapshot to evaluate.
Return
the signals that fired, possibly empty.
Parameters
limits that decide when a signal fires.
Derives heuristic PoolSignals from a chronological series of TraceEvent.PoolSamples, such as those a PoolSampler emits. Each label is evaluated on its own over its last minSamples samples; a label with fewer samples yields no signal.
PoolSignal.BacklogGrowing:
pendingis non-decreasing across the window, ends higher than it started and is positive.PoolSignal.PoolSaturated: in every sample of the window
parallelismis known,running >= parallelismandpending > 0.
These are heuristics, not proof: pending can overcount (see TraceEvent.PoolSample) and parallelism may be inferred. The result is ordered by the first appearance of each label.
Example:
val samples = ring.snapshot().filterIsInstance<TraceEvent.PoolSample>()
samples.signals().forEach(::println)Receiver
chronological samples, possibly from several dispatcher labels.
Return
the signals that fired, possibly empty.
Parameters
size of the window per label. Must be at least 2.
Throws
if minSamples is less than 2.