MCPcopy Index your code
hub / github.com/LatencyUtils/LatencyUtils

github.com/LatencyUtils/LatencyUtils @LatencyUtils-2.0.3

Chat with this repo
repository ↗ · DeepWiki ↗ · release LatencyUtils-2.0.3 ↗ · + Follow
144 symbols 335 edges 16 files 50 documented · 35% 2 cross-repo links
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

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

Extension points exported contracts — how you extend this code

PauseDetectorListener (Interface)
Accepts pause notification events. All times and time units are in nanoseconds [5 implementers]
src/main/java/org/LatencyUtils/PauseDetectorListener.java

Core symbols most depended-on inside this repo

nanoTime
called by 50
src/main/java/org/LatencyUtils/TimeServices.java
moveTimeForward
called by 23
src/main/java/org/LatencyUtils/TimeServices.java
getEstimatedInterval
called by 20
src/main/java/org/LatencyUtils/TimeCappedMovingAverageIntervalEstimator.java
recordInterval
called by 15
src/main/java/org/LatencyUtils/TimeCappedMovingAverageIntervalEstimator.java
getIntervalHistogram
called by 14
src/main/java/org/LatencyUtils/LatencyStats.java
moveTimeForwardMsec
called by 12
src/main/java/org/LatencyUtils/TimeServices.java
skipConsensusTimeTo
called by 9
src/main/java/org/LatencyUtils/SimplePauseDetector.java
getEstimatedInterval
called by 9
src/main/java/org/LatencyUtils/IntervalEstimator.java

Shape

Method 109
Class 33
Enum 1
Interface 1

Languages

Java100%

Modules by API surface

src/main/java/org/LatencyUtils/LatencyStats.java33 symbols
src/main/java/org/LatencyUtils/TimeServices.java24 symbols
src/main/java/org/LatencyUtils/TimeCappedMovingAverageIntervalEstimator.java14 symbols
src/main/java/org/LatencyUtils/PauseDetector.java13 symbols
src/main/java/org/LatencyUtils/SimplePauseDetector.java9 symbols
src/test/java/org/LatencyUtils/SimplePauseDetectorTest.java8 symbols
src/examples/java/LatencyLoggingDemo.java7 symbols
src/examples/java/LatencyComparativeLoggingDemo.java7 symbols
src/test/java/org/LatencyUtils/TimeCappedMovingAverageIntervalEstimatorTest.java6 symbols
src/main/java/org/LatencyUtils/MovingAverageIntervalEstimator.java6 symbols
src/examples/java/LatencyStatsDemo.java6 symbols
src/test/java/org/LatencyUtils/LatencyStatsTest.java4 symbols

Used by 2 indexed graphs manifest dependencies, hub-wide

For agents

$ claude mcp add LatencyUtils \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact