Package io.dropwizard.metrics5
Class LockFreeExponentiallyDecayingReservoir
java.lang.Object
io.dropwizard.metrics5.LockFreeExponentiallyDecayingReservoir
- All Implemented Interfaces:
Reservoir
A lock-free exponentially-decaying random reservoir of
long
s. Uses Cormode et al's
forward-decaying priority reservoir sampling method to produce a statistically representative
sampling reservoir, exponentially biased towards newer entries.- Author:
- Carter Kozak
- See Also:
-
-
Cormode et al. Forward Decay: A Practical Time Decay Model for Streaming Systems. ICDE '09:
Proceedings of the 2009 IEEE International Conference on Data Engineering (2009)
LockFreeExponentiallyDecayingReservoir is based closely on the ExponentiallyDecayingReservoir, however it provides looser guarantees while completely avoiding locks.
Looser guarantees:
- Updates which occur concurrently with rescaling may be discarded if the orphaned state node is updated after rescale has replaced it. This condition has a greater probability as the rescale interval is reduced due to the increased frequency of rescaling. #rescaleThresholdNanos values below 30 seconds are not recommended.
- Given a small rescale threshold, updates may attempt to rescale into a new bucket, but lose the CAS race and update into a newer bucket than expected. In these cases the measurement weight is reduced accordingly.
- In the worst case, all concurrent threads updating the reservoir may attempt to rescale rather than a single thread holding an exclusive write lock. It's expected that the configuration is set such that rescaling is substantially less common than updating at peak load. Even so, when size is reasonably small it can be more efficient to rescale than to park and context switch.
-
Cormode et al. Forward Decay: A Practical Time Decay Model for Streaming Systems. ICDE '09:
Proceedings of the 2009 IEEE International Conference on Data Engineering (2009)
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final class
By default this uses a size of 1028 elements, which offers a 99.9% confidence level with a 5% margin of error assuming a normal distribution, and an alpha factor of 0.015, which heavily biases the reservoir to the past 5 minutes of measurements. -
Method Summary
-
Method Details
-
size
public int size()Description copied from interface:Reservoir
Returns the number of values recorded. -
update
public void update(long value) Description copied from interface:Reservoir
Adds a new recorded value to the reservoir. -
getSnapshot
Description copied from interface:Reservoir
Returns a snapshot of the reservoir's values.- Specified by:
getSnapshot
in interfaceReservoir
- Returns:
- a snapshot of the reservoir's values
-
builder
-