public class DecayingEstimatedHistogramReservoir
extends java.lang.Object
implements com.codahale.metrics.Reservoir
Snapshot
will expose the decay functionality with the exception of the Snapshot.getValues()
which will return values
from the reservoir without decay. This makes it possible for the caller to maintain precise deltas in an interval of
its choice.
The bucket size starts at 1 and grows by 1.2 each time (rounding and removing duplicates). It goes from 1 to around
18T by default (creating 164+1 buckets), which will give a timing resolution from microseconds to roughly 210 days,
with less precision as the numbers get larger.
The series of values to which the counts in `decayingBuckets` correspond:
1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 17, 20, 24, 29, 35, 42, 50, 60, 72 etc.
Thus, a `decayingBuckets` of [0, 0, 1, 10] would mean we had seen 1 value of 3 and 10 values of 4.
Each bucket represents values from (previous bucket offset, current offset].
To reduce contention each logical bucket is striped accross a configurable number of stripes (default: 2). Threads are
assigned to specific stripes. In addition, logical buckets are distributed across the physical storage to reduce conention
when logically adjacent buckets are updated. See CASSANDRA-15213.
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_BUCKET_COUNT
The default number of decayingBuckets.
|
static int |
DEFAULT_STRIPE_COUNT |
static long[] |
DEFAULT_WITH_ZERO_BUCKET_OFFSETS |
static long[] |
DEFAULT_WITHOUT_ZERO_BUCKET_OFFSETS |
static boolean |
DEFAULT_ZERO_CONSIDERATION |
static long |
HALF_TIME_IN_S |
static long |
LANDMARK_RESET_INTERVAL_IN_MS |
static int |
MAX_BUCKET_COUNT |
static double |
MEAN_LIFETIME_IN_S |
Constructor and Description |
---|
DecayingEstimatedHistogramReservoir()
Construct a decaying histogram with default number of buckets and without considering zeroes.
|
DecayingEstimatedHistogramReservoir(boolean considerZeroes)
Construct a decaying histogram with default number of buckets.
|
DecayingEstimatedHistogramReservoir(boolean considerZeroes,
int bucketCount,
int stripes)
Construct a decaying histogram.
|
DecayingEstimatedHistogramReservoir(com.codahale.metrics.Clock clock) |
Modifier and Type | Method and Description |
---|---|
void |
clear() |
static float |
fastLog12(long v) |
static int |
findIndex(long[] bucketOffsets,
long value) |
com.codahale.metrics.Snapshot |
getSnapshot()
Returns a snapshot of the decaying values in this reservoir.
|
void |
rebase(org.apache.cassandra.metrics.DecayingEstimatedHistogramReservoir.EstimatedHistogramReservoirSnapshot snapshot)
Replaces current internal values with the given one from a Snapshot.
|
int |
size()
Returns the logical number of buckets where recorded values are stored.
|
int |
stripeCount() |
int |
stripedIndex(int offsetIndex,
int stripe) |
void |
update(long value)
Increments the count of the bucket closest to n, rounding UP.
|
void |
updateBucket(java.util.concurrent.atomic.AtomicLongArray buckets,
int index,
long value) |
public static final int DEFAULT_BUCKET_COUNT
public static final int DEFAULT_STRIPE_COUNT
public static final int MAX_BUCKET_COUNT
public static final boolean DEFAULT_ZERO_CONSIDERATION
public static final long[] DEFAULT_WITHOUT_ZERO_BUCKET_OFFSETS
public static final long[] DEFAULT_WITH_ZERO_BUCKET_OFFSETS
public static final long HALF_TIME_IN_S
public static final double MEAN_LIFETIME_IN_S
public static final long LANDMARK_RESET_INTERVAL_IN_MS
public DecayingEstimatedHistogramReservoir()
public DecayingEstimatedHistogramReservoir(boolean considerZeroes)
considerZeroes
- when true, 0-value measurements in a separate bucket, otherwise they will be collected in
same bucket as 1-value measurementspublic DecayingEstimatedHistogramReservoir(boolean considerZeroes, int bucketCount, int stripes)
considerZeroes
- when true, 0-value measurements in a separate bucket, otherwise they will be collected in
same bucket as 1-value measurementsbucketCount
- number of buckets used to collect measured valuespublic DecayingEstimatedHistogramReservoir(com.codahale.metrics.Clock clock)
public static float fastLog12(long v)
public void update(long value)
update
in interface com.codahale.metrics.Reservoir
value
- the data point to add to the histogrampublic void updateBucket(java.util.concurrent.atomic.AtomicLongArray buckets, int index, long value)
public int stripedIndex(int offsetIndex, int stripe)
public static int findIndex(long[] bucketOffsets, long value)
public int size()
Reservoir
interface.size
in interface com.codahale.metrics.Reservoir
stripeCount()
public int stripeCount()
public com.codahale.metrics.Snapshot getSnapshot()
getSnapshot
in interface com.codahale.metrics.Reservoir
public void clear()
public void rebase(org.apache.cassandra.metrics.DecayingEstimatedHistogramReservoir.EstimatedHistogramReservoirSnapshot snapshot)
Copyright © 2009-2021 The Apache Software Foundation