You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We observed extra allocations in the execute function due to a mismatch between the buffer size passed into snappy and the buffer size that snappy needs to handle the worst case compression outcome.
Component(s)
exporter/prometheusremotewrite
What happened?
Description
We observed extra allocations in the execute function due to a mismatch between the buffer size passed into snappy and the buffer size that snappy needs to handle the worst case compression outcome.
Specifically this code in snappy generates a buffer size > the size of the input buffer:
https://github.com/golang/snappy/blob/master/encode.go#L24
But the buffer allocated and passed into snappy is only equal to the size of our input buffer:
https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/exporter/prometheusremotewriteexporter/exporter.go#L277
Therefore snappy ends up allocating an extra buffer and the buffer allocated by prometheus remote write is unused.
Solution is to just not pre-allocate the buffer and pass nil which is valid per the snappy documentation.
This double allocation is responsible for ~10% of overall allocations in our otel collector after fixing
#34269
Steps to Reproduce
Use go tool pprof to profile memory allocations of the prometheus remote write exporter
Expected Result
Compression allocates a single buffer to handle the export
Actual Result
We allocate an extra buffer in execute which then does not get used by the snappy function.
Collector version
v0.101.0
Environment information
Environment
OS: (e.g., "Ubuntu 20.04")
Compiler(if manually compiled): (e.g., "go 14.2")
OpenTelemetry Collector configuration
No response
Log output
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: