recordLatency, which provides a thread safe, wait free, and lossless recording method.
The accumulated behavior across the recorded latencies in a given LatencyStats instance can be
examined in detail using interval and accumulated HdrHistogram histograms
(see org.HdrHistogram.Histogram ).
LatencyStats instances maintain internal histogram data that track all recoded latencies. Interval
histogram data can be sampled with the getIntervalHistogram,
getIntervalHistogramInto, or addIntervalHistogramTo calls.
Recorded latencies are auto-corrected for experienced pauses by leveraging pause detectors and
moving window average interval estimators, compensating for coordinated omission. While typical
histogram use deals with corrected data, LatencyStats instances do keep track of the raw,
uncorrected records, which can be accessed via the getLatestUncorrectedIntervalHistogram
and getLatestUncorrectedIntervalHistogramInto calls.
LatencyStats objects can be instantiated either directly via the provided constructors, or by
using the fluent API builder supported by org..
recordLatency, each
LatencyStats instance maintains an internal interval estimator that tracks the expected
interval between latency recordings. Whenever a stall in measurement is detected by a given
pause detector, each LatencyStats instances that uses that pause detector will be notified,
and will generate correcting latency entries (that are separately tracked internally).
Correcting latency entries are computed to "fill in" detected measurement pauses by projecting
the observed recording rate into the pause gap, and creating a linearly diminishing latency
measurement for each missed recording interval.
Pause detection and interval estimation are both configurable, and each LatencyStats instance can operate with potentially independent pause detector and interval estimator settings.
A configurable default pause detector is (by default) shared between LatencyStats instances
that are not provided with a specific pause detector at instantiation. If the default pause
detector is not explicitly set, it will itself default to creating (and starting) a single
instance of org., which uses consensus observation
of a pause across multiple observing threads as a detection technique.
Custom pause detectors can be provided (by subclassing org.).
E.g. a pause detector that pauses GC log output rather than directly measuring observations
can be constructed. A custom pause detector can be especially useful in situations where a
stall in the operation and latency measurement of an application's is known and detectable
by the application level, but would not be detectable as a process-wide stall in execution
(which org. is built to detect).
Interval estimation is done by using a time-capped moving window average estimator, with
the expected interval computed to be the average of measurement intervals within the window
(with the window being capped by both count and time). See
TimeCappedMovingAverageIntervalEstimator for more details. The estimator window
length and time cap can both be configured when instantiating a LatencyStats object
(defaults are 1024, and 10 seconds).
| Modifier and Type | Class and Description |
|---|---|
| public static class | LatencyStats.Builder
A fluent API builder class for creating LatencyStats objects. |
| private static class | LatencyStats.PauseTracker
PauseTracker is used to feed pause correction histograms whenever a pause is reported: |
| Modifier and Type | Field and Description |
|---|---|
| private Histogram | |
| private volatile AtomicHistogram | |
| private static LatencyStats. | |
| private static PauseDetector | |
| private final long | |
| private Histogram | |
| private AtomicHistogram | |
| private final IntervalEstimator | |
| private static final TimeServices. | |
| private final long | |
| private final int | |
| private final PauseDetector | |
| private final LatencyStats. | |
| private final WriterReaderPhaser |
| Access | Constructor and Description |
|---|---|
| public | |
| public | LatencyStats(final long
Lowest trackable latency in latency histograms lowestTrackableLatency, final long Highest trackable latency in latency histograms highestTrackableLatency, final int Number of significant [decimal] digits of accuracy in latency histograms numberOfSignificantValueDigits, final int Length of window in moving window interval estimator intervalEstimatorWindowLength, final long Time cap (in nanoseconds) of window in moving window interval estimator intervalEstimatorTimeCap, final PauseDetector The pause detector to use for identifying and correcting for pauses pauseDetector)
|
| Modifier and Type | Method and Description |
|---|---|
| public synchronized void | addIntervalHistogramTo(Histogram
the histogram into which the interval histogram's data should be added toHistogram)Add the values value counts accumulated since the last interval histogram was taken
into |
| public static PauseDetector | Returns: the current default pause detectorGet the current default pause detector which will be used by newly constructed LatencyStats instances when the constructor is not explicitly provided with one. |
| public IntervalEstimator | Returns: the IntervalEstimator used by this LatencyStats objectget the IntervalEstimator used by this LatencyStats object |
| public synchronized Histogram | Returns: a copy of the latest interval latency histogramGet a new interval histogram which will include the value counts accumulated since the last interval histogram was taken. |
| public synchronized void | getIntervalHistogramInto(Histogram
the histogram into which the interval histogram's data should be copied targetHistogram)Place a copy of the value counts accumulated since the last interval histogram
was taken into |
| public synchronized Histogram | Returns: a copy of the latest uncorrected interval latency histogramGet a copy of the uncorrected latest interval latency histogram. |
| public synchronized void | getLatestUncorrectedIntervalHistogramInto(Histogram
the histogram into which the interval histogram's data should be copied targetHistogram)Place a copy of the values of the latest uncorrected interval latency histogram. |
| public PauseDetector | Returns: the PauseDetector used by this LatencyStats objectget the PauseDetector used by this LatencyStats object |
| private synchronized void | |
| public void | recordLatency(long
latency value (in nanoseconds) to record latency)Record a latency value in the LatencyStats object |
| public static void | setDefaultPauseDetector(PauseDetector
the pause detector to use as a default when no explicit pause detector is provided pauseDetector)Set the default pause detector for the LatencyStats class. |
| public synchronized void | stop()
Stop operation of this LatencyStats object, removing it from the pause detector's notification list |
| private synchronized void | |
| private void | |
| private void | |
| private void | |
| private synchronized void |
| activePauseCorrectionsHistogram | back to summary |
|---|---|
| private Histogram activePauseCorrectionsHistogram | |
| activeRecordingHistogram | back to summary |
|---|---|
| private volatile AtomicHistogram activeRecordingHistogram | |
| defaultBuilder | back to summary |
|---|---|
| private static LatencyStats. | |
| defaultPauseDetector | back to summary |
|---|---|
| private static PauseDetector defaultPauseDetector | |
| highestTrackableLatency | back to summary |
|---|---|
| private final long highestTrackableLatency | |
| inactivePauseCorrectionsHistogram | back to summary |
|---|---|
| private Histogram inactivePauseCorrectionsHistogram | |
| inactiveRawDataHistogram | back to summary |
|---|---|
| private AtomicHistogram inactiveRawDataHistogram | |
| intervalEstimator | back to summary |
|---|---|
| private final IntervalEstimator intervalEstimator | |
| latencyStatsScheduledExecutor | back to summary |
|---|---|
| private static final TimeServices. | |
| lowestTrackableLatency | back to summary |
|---|---|
| private final long lowestTrackableLatency | |
| numberOfSignificantValueDigits | back to summary |
|---|---|
| private final int numberOfSignificantValueDigits | |
| pauseDetector | back to summary |
|---|---|
| private final PauseDetector pauseDetector | |
| pauseTracker | back to summary |
|---|---|
| private final LatencyStats. | |
| recordingPhaser | back to summary |
|---|---|
| private final WriterReaderPhaser recordingPhaser | |
| LatencyStats | back to summary |
|---|---|
| public LatencyStats() Create a LatencyStats object with default settings.
| |
| LatencyStats | back to summary |
|---|---|
public LatencyStats(final long lowestTrackableLatency, final long highestTrackableLatency, final int numberOfSignificantValueDigits, final int intervalEstimatorWindowLength, final long intervalEstimatorTimeCap, final PauseDetector pauseDetector)
| |
| addIntervalHistogramTo | back to summary |
|---|---|
| public synchronized void addIntervalHistogramTo(Histogram toHistogram) Add the values value counts accumulated since the last interval histogram was taken
into
| |
| getDefaultPauseDetector | back to summary |
|---|---|
| public static PauseDetector getDefaultPauseDetector() Get the current default pause detector which will be used by newly constructed LatencyStats instances when the constructor is not explicitly provided with one.
| |
| getIntervalEstimator | back to summary |
|---|---|
| public IntervalEstimator getIntervalEstimator() get the IntervalEstimator used by this LatencyStats object
| |
| getIntervalHistogram | back to summary |
|---|---|
| public synchronized Histogram getIntervalHistogram() Get a new interval histogram which will include the value counts accumulated since the last interval histogram was taken.
Calling
| |
| getIntervalHistogramInto | back to summary |
|---|---|
| public synchronized void getIntervalHistogramInto(Histogram targetHistogram) Place a copy of the value counts accumulated since the last interval histogram
was taken into
| |
| getLatestUncorrectedIntervalHistogram | back to summary |
|---|---|
| public synchronized Histogram getLatestUncorrectedIntervalHistogram() Get a copy of the uncorrected latest interval latency histogram. Values will not include
corrections for detected pauses. The interval histogram copies will include all values points
captured up to the latest call to call to one of
| |
| getLatestUncorrectedIntervalHistogramInto | back to summary |
|---|---|
| public synchronized void getLatestUncorrectedIntervalHistogramInto(Histogram targetHistogram) Place a copy of the values of the latest uncorrected interval latency histogram. Values will not include
corrections for detected pauses. The interval histogram copies will include all values points
captured up to the latest call to call to one of
| |
| getPauseDetector | back to summary |
|---|---|
| public PauseDetector getPauseDetector() get the PauseDetector used by this LatencyStats object
| |
| recordDetectedPause | back to summary |
|---|---|
| private synchronized void recordDetectedPause(long pauseLength, long pauseEndTime) | |
| recordLatency | back to summary |
|---|---|
| public void recordLatency(long latency) Record a latency value in the LatencyStats object
| |
| setDefaultPauseDetector | back to summary |
|---|---|
| public static void setDefaultPauseDetector(PauseDetector pauseDetector) Set the default pause detector for the LatencyStats class. Used by constructors that do not explicitly provide a pause detector.
| |
| stop | back to summary |
|---|---|
| public synchronized void stop() Stop operation of this LatencyStats object, removing it from the pause detector's notification list | |
| swapHistograms | back to summary |
|---|---|
| private synchronized void swapHistograms() | |
| swapPauseCorrectionHistograms | back to summary |
|---|---|
| private void swapPauseCorrectionHistograms() | |
| swapRecordingHistograms | back to summary |
|---|---|
| private void swapRecordingHistograms() | |
| trackRecordingInterval | back to summary |
|---|---|
| private void trackRecordingInterval() | |
| updateHistograms | back to summary |
|---|---|
| private synchronized void updateHistograms() | |
| Modifier and Type | Field and Description |
|---|---|
| private long | |
| private long | |
| private int | |
| private long | |
| private int | |
| private PauseDetector |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public LatencyStats | |
| public static LatencyStats. | |
| public LatencyStats. | |
| public LatencyStats. | |
| public LatencyStats. | |
| public LatencyStats. | |
| public LatencyStats. | |
| public LatencyStats. |
| highestTrackableLatency | back to summary |
|---|---|
| private long highestTrackableLatency | |
| intervalEstimatorTimeCap | back to summary |
|---|---|
| private long intervalEstimatorTimeCap | |
| intervalEstimatorWindowLength | back to summary |
|---|---|
| private int intervalEstimatorWindowLength | |
| lowestTrackableLatency | back to summary |
|---|---|
| private long lowestTrackableLatency | |
| numberOfSignificantValueDigits | back to summary |
|---|---|
| private int numberOfSignificantValueDigits | |
| pauseDetector | back to summary |
|---|---|
| private PauseDetector pauseDetector | |
| Builder | back to summary |
|---|---|
| public Builder() | |
| build | back to summary |
|---|---|
| public LatencyStats build() | |
| create | back to summary |
|---|---|
| public static LatencyStats. | |
| highestTrackableLatency | back to summary |
|---|---|
| public LatencyStats. | |
| intervalEstimatorTimeCap | back to summary |
|---|---|
| public LatencyStats. | |
| intervalEstimatorWindowLength | back to summary |
|---|---|
| public LatencyStats. | |
| lowestTrackableLatency | back to summary |
|---|---|
| public LatencyStats. | |
| numberOfSignificantValueDigits | back to summary |
|---|---|
| public LatencyStats. | |
| pauseDetector | back to summary |
|---|---|
| public LatencyStats. | |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv final PauseDetector |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public void | handlePauseEvent(final long
Length of reported pause (in nanoseconds) pauseLength, final long Time sampled at end of reported pause (in nanoTime units). pauseEndTime)Implements org. |
| public void |
| pauseDetector | back to summary |
|---|---|
| pack-priv final PauseDetector pauseDetector | |
| PauseTracker | back to summary |
|---|---|
| pack-priv PauseTracker(final PauseDetector pauseDetector, final LatencyStats latencyStats) | |
| handlePauseEvent | back to summary |
|---|---|
| public void handlePauseEvent(final long pauseLength, final long pauseEndTime) Implements org. Doc from org. handle a pause event notification.
| |
| stop | back to summary |
|---|---|
| public void stop() | |