Class LockFreeExponentiallyDecayingReservoir

  • All Implemented Interfaces:
    com.codahale.metrics.Reservoir

    @Beta
    public final class LockFreeExponentiallyDecayingReservoir
    extends java.lang.Object
    implements com.codahale.metrics.Reservoir
    LockFreeExponentiallyDecayingReservoir is based closely on the codahale ExponentiallyDecayingReservoir.java, however it provides looser guarantees while completely avoiding locks. This implementation is being contributed upstream: metrics#1656 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.
    See ExponentiallyDecayingReservoir Copyright 2010-2012 Coda Hale and Yammer, Inc. Licensed under the Apache License, Version 2.0. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
    • Method Detail

      • size

        public int size()
        Specified by:
        size in interface com.codahale.metrics.Reservoir
      • update

        public void update​(long value)
        Specified by:
        update in interface com.codahale.metrics.Reservoir
      • getSnapshot

        public com.codahale.metrics.Snapshot getSnapshot()
        Specified by:
        getSnapshot in interface com.codahale.metrics.Reservoir