forked from open-telemetry/opentelemetry-collector-contrib
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[prometheusremotewriteexporter] reduce allocations when serializing p…
…rotobufs (open-telemetry#35185) **Description:** <Describe what has changed.> <!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> There are two allocations that happen on every push 1. Serializing the remote write protobuf to a byte array. 2. Compressing the byte array with snappy. Since these buffers can be quite large, we can save some allocations with a `sync.Pool`. **Link to tracking Issue:** <Issue number if applicable> **Testing:** Tests still pass. We have been running this successfully in production for a few months now. ``` │ /tmp/old.txt │ /tmp/new.txt │ │ sec/op │ sec/op vs base │ Execute/numSample=100-14 43.11µ ± 2% 43.09µ ± 2% ~ (p=0.853 n=10) Execute/numSample=1000-14 105.4µ ± 1% 102.2µ ± 1% -3.04% (p=0.000 n=10) Execute/numSample=10000-14 685.5µ ± 1% 663.6µ ± 5% -3.19% (p=0.023 n=10) geomean 146.0µ 143.0µ -2.10% │ /tmp/old.txt │ /tmp/new.txt │ │ B/op │ B/op vs base │ Execute/numSample=100-14 14.809Ki ± 0% 6.091Ki ± 0% -58.87% (p=0.000 n=10) Execute/numSample=1000-14 94.18Ki ± 0% 22.16Ki ± 0% -76.47% (p=0.000 n=10) Execute/numSample=10000-14 726.23Ki ± 0% 39.83Ki ± 0% -94.52% (p=0.000 n=10) geomean 100.4Ki 17.52Ki -82.56% │ /tmp/old.txt │ /tmp/new.txt │ │ allocs/op │ allocs/op vs base │ Execute/numSample=100-14 81.00 ± 0% 79.00 ± 0% -2.47% (p=0.000 n=10) Execute/numSample=1000-14 85.00 ± 0% 83.00 ± 0% -2.35% (p=0.000 n=10) Execute/numSample=10000-14 85.00 ± 0% 83.00 ± 0% -2.35% (p=0.000 n=10) geomean 83.65 81.64 -2.39% ``` **Documentation:** <Describe the documentation added.> --------- Co-authored-by: David Ashpole <[email protected]>
- Loading branch information
Showing
3 changed files
with
151 additions
and
3 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
.chloggen/prometheusremotewriteexporter-optimize-serialization.yaml
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: prometheusremotewriteexporter | ||
|
||
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). | ||
note: reduce allocation when serializing protobuf | ||
|
||
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. | ||
issues: [35185] | ||
|
||
# (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: [] |
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