Top Description Interfaces Classes
[default module]

Package org.LatencyUtils


A latency stats tracking package

The LatencyUtils package includes useful utilities for tracking latencies. Especially in common in-process recording scenarios, which can exhibit significant coordinated omission sensitivity without proper handling. org.LatencyUtils.LatencyStats instances are used to track recorded latencies in the common use case the often follow this pattern:


LatencyStats myOpStats = new LatencyStats();
...

// During normal operation, record all operation latencies into a LatencyStats instance:

long startTime = System.nanoTime();
// Perform operation:
doMyOperation(...);
// Record operation latency:
myOpStats.recordLatency(System.nanoTime() - startTime);
...

// Later, report on stats collected:
Histogram intervalHistogram = myOpStats.getIntervalHistogram();

intervalHistogram.getHistogramData().outputPercentileDistribution(System.out, 1000000.0);


The problem

Latency tracking of in-process operations usually consists simple time sampling around a tracked operation. E.g. a database read operation for which latency statistics are being developed may be surrounded by time measurement operation immediately before and after the operation is performed, with the difference in time recorded in some aggregate statistics gathering form (average, std. deviation, histogram,. etc.) which is later used to report on the experienced latency behavior of the tracked operation.

The problem with this extremely common form of latency behavior tracking is that whenever pauses occur in the system, latency statistics become significantly skewed toward falsely-optimistic values. This occurs in two key ways:

The Solution

The org.LatencyUtils.LatencyStats class is designed for simple, drop-in use as a latency behavior recording object in common in-process latency recording and tracking situations. LatencyStats includes under-the-hood tracking and correction of pause effects, compensating for coordinated omission. It does so by using pluggable pause detectors and interval estimators that together with org.LatencyUtils.LatencyStats will transparently produce corrected histogram values for the recorded latency behavior.

Interface Summary

Modifier and TypeInterface and Description
public interface
PauseDetectorListener

Accepts pause notification events.

Class Summary

Modifier and TypeClass and Description
public abstract class
IntervalEstimator

IntervalEstimator is used to estimate intervals, potentially based on observed intervals recorded in it.

public class
LatencyStats

LatencyStats objects are used to track and report on the behavior of latencies across measurements.

public class
MovingAverageIntervalEstimator

A moving average interval estimator.

public abstract class
PauseDetector

A PauseDetector detects pauses and reports them to registered listeners

public class
SimplePauseDetector

A Simple PauseDetector that detects pauses using a consensus observation across a configurable number of detection thread.

public class
TimeCappedMovingAverageIntervalEstimator

A moving average interval estimator with a cap on the time window length that the moving window must completely fit in in order to provide estimated time intervals.

public class
TimeServices

Provide an API for time-related service, such as getting the current time and waiting for a given period of time.