opentelemetry-cpp icon indicating copy to clipboard operation
opentelemetry-cpp copied to clipboard

[EXPORTER] optimize OTLP HTTP compression

Open marcalff opened this issue 11 months ago • 3 comments

Investigate and/or implement possible performance improvements.

Related to this idea from #2530

Do you think we can use the in-place compression of the data without using a separate output buffer compressed_body, as suggested here - https://stackoverflow.com/questions/12398377/is-it-possible-to-have-zlib-read-from-and-write-to-the-same-memory-buffer/12412863#12412863. This is suggested by "Mark Adler", the author of zlib, and would be better memory optimzation in the hot-path of upload.

marcalff avatar Feb 29 '24 17:02 marcalff

This issue is available for anyone to work on. Make sure to reference this issue in your pull request. :sparkles: Thank you for your contribution! :sparkles:

github-actions[bot] avatar Feb 29 '24 17:02 github-actions[bot]

Hi, I looked at implementing in-place zlib compression suggested by @lalitb. A couple of issues that I need some help with:

  1. For the case where the data is insufficiently compressible, the function allocates a temporary buffer, copies the remaining uncompressed data into it, and then completes the compression from the temporary buffer into the remaining space in the output buffer. To avoid this scenario, the author recommends to set max to be equal to deflateBound(stream, len). If we follow the same advice, then do we resize http_requrest->body before every compression, or do we resize only when the function fails with Z_BUF_ERROR and then resize the buffer and retry compression?

  2. The deflate stream can be reused across multiple calls, but is not thread safe. From what I can see, the Session::SendRequest method seems to be used in a thread-safe way in the OtlpHttp exporter. If so, we can initialize the stream object once per session and reuse it for multiple requests.

perhapsmaple avatar Mar 26 '24 16:03 perhapsmaple

This issue was marked as stale due to lack of activity.

github-actions[bot] avatar May 26 '24 01:05 github-actions[bot]