Skip to content
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

Use EstimatedHistogram in metricPercentilesAsArray(JmxHistogramMBean) #331

Closed
wants to merge 1 commit into from

Conversation

Deexie
Copy link
Contributor

@Deexie Deexie commented Apr 18, 2023

NodeProbe::metricPercentilesAsArray(JmxHistogramMBean) is expected
to return an array with percentiles obtained from a given histogram.
Currently BufferSamples object is created out of the original jmx
histogram's values and its getValue method is used to create an array.
BufferSamples::getValue(double) expects data in different format than
the provided one, though.

EstimatedHistogram, which is compactible with original histogram,
is created out of metric values.

Fixes: #330.

@Deexie
Copy link
Contributor Author

Deexie commented Apr 18, 2023

@tarzanek @amnonh @bhalevy review please

@@ -1594,15 +1594,13 @@ public long getStorageMetric(String metricName)

public double[] metricPercentilesAsArray(CassandraMetricsRegistry.JmxHistogramMBean metric)
{
BufferSamples bs = new BufferSamples(metric.values());
Copy link
Contributor

Choose a reason for hiding this comment

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

I expect this was to get some caching done, by removing this we will loose this caching
for direct fetching (ala histograms) it won't be a prob
but I can imagine this can be a prob e.g. for e.g. toppartitions which does sampling and polls periodically, can you test your change with toppartitions? ( or if it doesn't use this call, then check all possible calls and make sure removing caching won't break them)

Copy link
Contributor

Choose a reason for hiding this comment

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

I see @amnonh introduced this wrapper , Amnon is it safe to get rid of it?

Copy link
Contributor

Choose a reason for hiding this comment

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

ref ee5e2b9
this explains why, so you are reverting Amnons optimalization ;-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, I see. How about moving the logic to jmx side? I mean adding metricPercentilesAsArray to jmx JmxHistogramMBean interface and then

public double[] metricPercentilesAsArray(CassandraMetricsRegistry.JmxHistogramMBean metric) {
    return metric.metricPercentilesAsArray();
}

We will have one call to jmx and be able to differentiate between the versions of histogram.

@amnonh
Copy link
Contributor

amnonh commented Apr 19, 2023

Inside Scylla, we have the old-style histograms we inherit from Cassandra and the new kind (actual histograms) these days for most of them we even have the derivative histogram, which is what we are really after in this case.
Maybe this is the path we should take?

Move to use the real histograms and deprecate the old kind.

@bhalevy
Copy link
Member

bhalevy commented Apr 19, 2023

@Deexie and I reviewed the code again today and it looks the bug is the intrrpretation of the JMXHistogramMBean values on the Nodetool NodeProbe side as buffer samples.

Let's see if we can reconstruct the EstimatedHistogram from values() using the HistogramBuilder and use it to retrieve the percentiles.

This way we preserve the fix of getting the values in a single call rather than a series of calls to get each percentile, and we do the conversion correctly.

NodeProbe::metricPercentilesAsArray(JmxHistogramMBean) is expected
to return an array with percentiles obtained from a given histogram.
Currently BufferSamples object is created out of the original jmx
histogram's values and its getValue method is used to create an array.
BufferSamples::getValue(double) expects data in different format than
the provided one, though.

EstimatedHistogram, which is compactible with original histogram,
is created out of metric values.

Fixes: scylladb#330.
@Deexie Deexie changed the title Use original jmx histogram in metricPercentilesAsArray Use EstimatedHistogram in metricPercentilesAsArray(JmxHistogramMBean) Apr 20, 2023
@Deexie Deexie requested a review from tarzanek April 20, 2023 16:36
eh.percentile(0.98),
eh.percentile(0.99),
eh.min(),
eh.max()};
Copy link
Member

Choose a reason for hiding this comment

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

Cool! Does it work? :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it does :D The results look reasonable and the test passes

@denesb denesb closed this in eb3c43f Apr 21, 2023
denesb pushed a commit that referenced this pull request Jul 31, 2023
NodeProbe::metricPercentilesAsArray(JmxHistogramMBean) is expected
to return an array with percentiles obtained from a given histogram.
Currently BufferSamples object is created out of the original jmx
histogram's values and its getValue method is used to create an array.
BufferSamples::getValue(double) expects data in different format than
the provided one, though.

EstimatedHistogram, which is compactible with original histogram,
is created out of metric values.

Fixes: #330.
Closes: #331.
(cherry picked from commit eb3c43f)
denesb pushed a commit that referenced this pull request Jul 31, 2023
NodeProbe::metricPercentilesAsArray(JmxHistogramMBean) is expected
to return an array with percentiles obtained from a given histogram.
Currently BufferSamples object is created out of the original jmx
histogram's values and its getValue method is used to create an array.
BufferSamples::getValue(double) expects data in different format than
the provided one, though.

EstimatedHistogram, which is compactible with original histogram,
is created out of metric values.

Fixes: #330.
Closes: #331.
(cherry picked from commit eb3c43f)
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.

Incorrect sstablesPerRead values
4 participants