-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
CASSANDRA-20333 Decaying histogram reservoir uses thread locals to store updates #4003
base: trunk
Are you sure you want to change the base?
Conversation
if (decaying.decayLandmark != decayingEstimatedBuckets.decayLandmark) | ||
decayingEstimatedBuckets.flush(this, decaying); | ||
|
||
decayingRef.get().update(index, now); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need to do this get always twice?
|
||
public void update(int index, long now) | ||
{ | ||
if (lastSampledClock != now) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
forwardDecayWeight actually uses seconds granularity, so we can reuse the value for much longer..
// try to use int[] instead of long[] to reduce memory usage, and move to the sum array when overflow | ||
private final AtomicReference<DecayingArray> decayingRef; | ||
private final long[] estimated; | ||
private volatile boolean writing; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
potential false sharing with the array reference and decayingRef..
{ | ||
// This is only called by the thread that owns the thread local, so we don't need to worry about contention. | ||
// Once the rescaling has occurred, we need to flush the values to the decayingBucket and report that the values are no longer in use. | ||
writing = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so, in the current implementation we have 2 volatile writes vs 2 addAndGet operations in the original one, without a contention they cost may be quite similar...
Thanks for sending a pull request! Here are some tips if you're new here:
Commit messages should follow the following format:
The Cassandra Jira