Mmuzaf commented on code in PR #3102:
URL: https://github.com/apache/cassandra/pull/3102#discussion_r1714202555
##########
src/java/org/apache/cassandra/metrics/DecayingEstimatedHistogramReservoir.java:
##########
@@ -371,42 +363,50 @@ private void rescaleIfNeeded(long now)
{
try
{
- rescale(now);
+ decayingBuckets = rescale(now);
Review Comment:
It seems that both `needRescale` and `rescale` should be calculated on the
same object reference. Currently it doesn't look like the same condition is
being met when the `rescale` method is run after checking `needRescale`, or am
I missing something?
The example:
```
private static final
AtomicReferenceFieldUpdater<DecayingEstimatedHistogramReservoir,
DecayingBuckets> decayingBucketsUpdater =
AtomicReferenceFieldUpdater.newUpdater(DecayingEstimatedHistogramReservoir.class,
DecayingBuckets.class, "decayingBuckets");
private void rescaleIfNeeded(long now)
{
DecayingBuckets buckets = decayingBuckets;
while (now - buckets.decayLandmark > LANDMARK_RESET_INTERVAL_IN_NS)
{
double rescaleFactor = buckets.forwardDecayWeight(now);
DecayingBuckets newBuckets = new DecayingBuckets(now);
for (int i = 0; i < buckets.buckets.length(); i++)
newBuckets.buckets.set(i, Math.round(buckets.buckets.get(i) /
rescaleFactor));
boolean success = decayingBucketsUpdater.compareAndSet(this,
buckets, newBuckets);
if (success)
return;
buckets = decayingBuckets;
}
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]