Skip to content

added sliding window histogram #200

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 6, 2016
Merged

added sliding window histogram #200

merged 3 commits into from
Dec 6, 2016

Conversation

robertroeser
Copy link
Member

Problem
Current histogram doesn't resets on every get on every dimension. This creates choppy metrics.

Modifications
Modified the timer to have n histrograms in a queue and rotate of over them to smooth out the histogram over a sliding window. Switched the dimensions of the histrogram to a label called value. Switched the reseting of the histrogram to a closure that is called by the timer instead so it will rotate the histrogram once per window.

Result
Correct metrics over a rolling window.

min = new HdrHistogramMinGauge(MonitorConfig.builder(label).withTag("value", "min").withTags(tags).build(), histogram);
max = new HdrHistogramMaxGauge(MonitorConfig.builder(label).withTag("value", "min").withTags(tags).build(), histogram);

p50 = new HdrHistogramGauge(MonitorConfig.builder(label).withTag("value", "p50").withTags(tags).build(), histogram, 50, this::slide);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will rotate the histogram for each slide of min, max, etc. Is that what you intend?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get min and max don't reset the histogram

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad. You are correct that min and max don't but 50,90,99,99_9,99_99 all do.

}

long value = histogram.aggregateHistogram().getValueAtPercentile(percentile);
slide.run();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could lead to unintentional sliding of the window. eg: If a user action fetches the value (eg: from a JMX console), it will reset the histogram.

Copy link
Member Author

@robertroeser robertroeser Dec 6, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

slide is passed in as a closure, and that method has a 1 minute timeout

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes but do you intend to slide (and in the other class, today it rotates the histogram) on every get ?

Copy link
Member Author

@robertroeser robertroeser Dec 6, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes - it'll only rotate now when the the timeout expires

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad, didn't see the timeout condition, thanks!

*/
public void rotateHistogram() {
histogramAtomicReference
.updateAndGet(old -> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since, the passed function to updateAndGet should be side-effect free (as per the javadoc), I don't think this is a good usage of updateAndGet.
Maybe this should be synchronized to disallow concurrent modification and simply rotate the histograms atomically.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah i can do that

*
* @return Aggregated histogramAtomicReference
*/
public Histogram aggregateHistogram() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since gets will most likely not be concurrent, done by the poller, do we need threadlocal isolation of aggregation? Synchronized aggregation may be simpler and efficient? Also, you are already synchronizing additions to the aggregate.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No it's be bad because sync would block the aggregations. One line 86 it adds the live one, and then in the sync block it adds the ones in the queue.
I can replace the thread local with a new object.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes the sync will block aggregations but one histogram will be used by one metric which will have one poller and hence there would only be a single thread calling aggregate isn't?

@NiteshKant NiteshKant merged commit 369d296 into rsocket:0.5.x Dec 6, 2016
NiteshKant pushed a commit that referenced this pull request Dec 8, 2016
Added sliding window histogram

Problem
Current histogram doesn't resets on every get on every dimension. This creates choppy metrics.

Modifications
Modified the timer to have n histrograms in a queue and rotate of over them to smooth out the histogram over a sliding window. Switched the dimensions of the histrogram to a label called value. Switched the reseting of the histrogram to a closure that is called by the timer instead so it will rotate the histrogram once per window.

Result
Correct metrics over a rolling window.
NiteshKant pushed a commit to NiteshKant/reactivesocket-java that referenced this pull request Dec 14, 2016
Added sliding window histogram

Problem
Current histogram doesn't resets on every get on every dimension. This creates choppy metrics.

Modifications
Modified the timer to have n histrograms in a queue and rotate of over them to smooth out the histogram over a sliding window. Switched the dimensions of the histrogram to a label called value. Switched the reseting of the histrogram to a closure that is called by the timer instead so it will rotate the histrogram once per window.

Result
Correct metrics over a rolling window.
ilayaperumalg pushed a commit to ilayaperumalg/rsocket-java that referenced this pull request Dec 26, 2017
* KEEPALIVE timing suggestions

- moved into SETUP where the value is
- include server-to-server and mobile-to-server commentary

* remove newline

* remove change

* soften language for 500ms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants