Git Product home page Git Product logo

latencyutils's Introduction

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. 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.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:

  • When a pause occurs during a tracked operation, a single long recorded latency will appear in the recorded values, with no long latencies associated with any pending requests that may be stalled by the pause.
  • When a pause occurs outside of the tracked operation (and outside of the tracked time window) no long latency value would be recorded, even though any requested operation would be stalled by the pause.

The Solution

The 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 LatencyStats will transparently produce corrected histogram values for the recorded latency behavior.

latencyutils's People

Contributors

daschl avatar dependabot[bot] avatar giltene avatar marshallpierce avatar philipa avatar quaff avatar rlodge avatar tobi5775 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

latencyutils's Issues

Give the PauseDetector thread a descriptive name

PauseDetector starts a thread without a name. This leads to the thread being assigned a generic name like "Thread-13" that is not easily identifiable.

It would be nice if the thread started by PauseDetector was given a descriptive name that included pause-detector or latency-pause-detector or something, so that it is easily identifiable in thread lists, stack dumps, etc.

`LatencyStats` equivalent to `Recorder#getIntervalHistogram(Histogram)`?

LatencyStats has getIntervalHistogram() and getIntervalHistogramInto(Histogram) and ``(Histogram)but doesn't have anything like HdrHistogram'sRecorder#getIntervalHistogram(Histogram)` that avoids holding the reader lock while copying into either a new or target histogram. To be fair, I haven't found a scalability problem in the current approach with actual usage, so I'm operating on the assumption that this is important because Recorder does it.

As far as I can tell, it's a little more complicated in LatencyStats because there are two histograms, but it seems like it would be workable to have a getBothIntervalHistograms(Histogram, Histogram) that takes a histogram for the raw data and another for the pause corrections, and a getIntervalHistograms() that returned a pair. Does this seem sensible?

The existing addIntervalHistogramTo is actually very convenient for my usage (https://bitbucket.org/marshallpierce/hdrhistogram-metrics-reservoir/commits/d6b5c43b612a447768b058f81e35898b953d3116?at=master#chg-src/main/java/org/mpierce/metrics/reservoir/hdrhistogram/LatencyStatsReservoir.java) but it would be almost as easy to manage the interval histograms myself and remove some work from the locked section.

BSD License?

Hi,

am I understanding your license right, that I can use it under the BSD-2-Clause?

Thank you so much!

Too many TimeCappedMovingAverageIntervalEstimator$PauseTracker garbage in old gen

We use LatencyUtils with redis client lettuce.
Lettuce will drop LatencyStats every 10 min, and call LatencyStats's stop method.

After some dig, I found out that LatencyStats's stop only remove LatencyStats$PauseTracker from PauseDetector, TimeCappedMovingAverageIntervalEstimator$PauseTracker left untouched. When TimeCappedMovingAverageIntervalEstimator got garbage collected, weak reference TimeCappedMovingAverageIntervalEstimator$PauseTracker will remove itself from PauseDetector and will be collected at next gc.

In my scenario,we use g1 as collector. 10 min is too long and TimeCappedMovingAverageIntervalEstimator$PauseTracker is already promoted to old gen. G1 only collects part of old gen when mixed gc, so old gen is grow slowly. This will in turn affect gc time and throughput.

Is it better to eager clean TimeCappedMovingAverageIntervalEstimator$PauseTracker when stop is called ?

image

forceIntervalSample() hangs forever

If some (any?) calls to currentRecordingHistogram.record fail (usually do to ArrayIndexOutOfBounds), calls to forceIntervalSample() hang forever.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.