-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[exporter/prometheusremotewrite] allocate smaller buffers for prometh…
…eus remote write batch time series (#34271) **Description:** Adjusting buffer allocations in prometheusremotewriteexporter.batchTimeSeries Rather than allocating the maximum possible size buffer each time we memoize the last buffer size that we actually used and allocate a 2x sized buffer for the next request. This ensures that we tend to allocate buffers sized appropriately for the requests and still avoid array resizing in most cases (unless the data point size changes by more than 2x from one request to the next). This reduces memory allocations and memory usage significantly in our testing when you have large batches. In the case that the request sizes never meet the max request size configured for the exporter the existing behavior will remain and we will continue to allocate a single buffer with a size equal to the number of time series / metric metadata objects passed in. There will still be a benefit of not allocating a huge requests buffer in this case since instead of allocating a buffer with a size equal to the number of total objects passed in we default to a buffer of size 10 or 2x the last number of requests whichever is larger. **Link to tracking Issue:** Fixes #34269 **Testing:** We have validated this fix in our test environment and existing unit tests cover this code. The observable behavior is unchanged as this just tweaks the pre-allocated size of the buffers. I can add some unit tests to validate the memoized buffer sizes once we agree on the proper place to store that memoization. **Documentation:** No documentation added as this is a perf optimization that doesn't have any user facing impact beyond reducing memory usage.
- Loading branch information
1 parent
42f9faa
commit 67a5891
Showing
4 changed files
with
146 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Use this changelog template to create an entry for release notes. | ||
|
||
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' | ||
change_type: enhancement | ||
|
||
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver) | ||
component: exporter/prometheusremotewrite | ||
|
||
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). | ||
note: Reduce memory allocations of prometheus remote write exporter "batchtimeseries" when large batch sizes are used | ||
|
||
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. | ||
issues: [34269] | ||
|
||
# (Optional) One or more lines of additional information to render under the primary note. | ||
# These lines will be padded with 2 spaces and then inserted directly into the document. | ||
# Use pipe (|) for multiline entries. | ||
subtext: | ||
|
||
# If your change doesn't affect end users or the exported elements of any package, | ||
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label. | ||
# Optional: The change log or logs in which this entry should be included. | ||
# e.g. '[user]' or '[user, api]' | ||
# Include 'user' if the change is relevant to end users. | ||
# Include 'api' if there is a change to a library API. | ||
# Default: '[user]' | ||
change_logs: [user] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters