-
Notifications
You must be signed in to change notification settings - Fork 278
PrometheusTimeSeries performance fixes #6316
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
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Kondaka <[email protected]>
| public List<TimeSeries> getTimeSeriesList() { | ||
| return timeSeriesList; | ||
| private int estimateLabelSize(String name, String value) { | ||
| return name.length() + value.length() + 8; // Approximate protobuf overhead |
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.
Make 8 a constant and name it APPROXIMATE_PROTOBUF_OVERHEAD.
| size += label.toByteArray().length; | ||
| Sample sample = Sample.newBuilder().setValue(sampleValue).setTimestamp(timestamp).build(); | ||
| size += sample.toByteArray().length; | ||
| size += estimateLabelSize(labelName, labelValue) + 16; // Sample overhead |
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.
Again, make 16 into a constant named SAMPLE_OVERHEAD. Better yet, is there a way to derive it as a constant?
| return timestamp; | ||
| } | ||
| public List<TimeSeries> getTimeSeriesList() { return timeSeriesList; } | ||
| public long getTimeStamp() { return timestamp; } |
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.
"Timestamp" is a single word, so this should be getTimestamp().
| public List<TimeSeries> getTimeSeriesList() { | ||
| return timeSeriesList; | ||
| private int estimateLabelSize(String name, String value) { | ||
| return name.length() + value.length() + 8; // Approximate protobuf overhead |
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.
Are you looking for length or size? This may not give you the actual value you are looking for.
I appreciate the desire to cut the extra buffer. But, the calculation may be incorrect. Could you add to the Remote.WriteRequest.Builder and get the value at that point to avoid double buffering?
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.
The 8 byte overhead includes on-wire overhead for labels for tags and length markers. Anyways, it would be approximate.
| Sample sample = Sample.newBuilder().setValue(sampleValue).setTimestamp(timestamp).build(); | ||
| size += sample.toByteArray().length; | ||
| final String labelValue, final Double sampleValue) { | ||
| size += estimateLabelSize(NAME_LABEL, metricName) + estimateLabelSize(labelName, labelValue) + 16; |
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.
What is 16 for? Similar to my other comments, make this a constant and give it a helpful name. e.g. INDIVIDUAL_TIME_SERIES_OVERHEAD.
|
These are good performance improvements. You should include a JMH test. See data-prepper-expression and http-source for examples of doing this. |
Signed-off-by: Kondaka <[email protected]>
|
@dlvenable will add JMH in a separate PR |
Description
Improved performance of PrometheusTimeSeries class by
creating new HashMaps each time
Also added negative credentials check integration test
Issues Resolved
Resolves #[Issue number to be closed when this PR is merged]
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.