Package org.acemq.workloads.metrics
Class LatencyRecorder
java.lang.Object
org.acemq.workloads.metrics.LatencyRecorder
Records latencies, from many threads, without distorting them.
Why a histogram and not a list
Two reasons, and both are fatal to the alternative.
Percentiles cannot be averaged. The mean of each thread's p99 is not the p99, and neither is the mean of each second's p99. Any design that summarises per thread or per interval and combines the summaries afterwards produces a number that is not a percentile of anything. The samples have to meet in one place.
A list does not fit. At 300,000 messages a second for five minutes that is ninety million longs — 720MB, allocated during the measurement, which the garbage collector then pays for in exactly the pauses being measured.
ConcurrentHistogram solves both: fixed memory, lock-free recording, and exact
percentiles to the configured precision.
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
LatencyRecorder
- Parameters:
name- what is being measured, for the report
-
-
Method Details
-
record
public void record(long nanos) - Parameters:
nanos- one observation
-
summary
- Returns:
- a snapshot of everything recorded so far
-
count
public long count()- Returns:
- how many observations have been recorded
-
reset
public void reset()Discards everything recorded so far, which is how warm-up is excluded. -
toString
-