-
Notifications
You must be signed in to change notification settings - Fork 35
Use more straightforward compression approach and buffer pool #79
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
Conversation
💚 Build Succeeded
Expand to view the summary
Build stats
Test stats 🧪
🤖 GitHub commentsTo re-run your PR in the CI, just comment with:
|
Is there a specific issue with |
Yes, there are no synchronization guarantees and the client could start issuing the request before the gzip writer had finished writing everything. If there's an error, the body would be incomplete. Using a buffer ensures that the data is properly gzipped before it is sent. |
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.
+1 on removing io.Pipe()
too, I think that going forward we could also have some micro benchmarks to get a good understanding of the impact.
I don't see an issue with that. In fact, I think that's preferable. It avoids unnecessarily copying from buffer to buffer. The Elastic APM Java agent is also directly serializing the events to the HTTP request body to avoid having to copy and allocate buffers. I have never seen a situation where compression would fail. |
I modified the PostToAPM function to accept an Overall it seems to be around 10% faster than the
|
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.
+1 for avoid concurrency complications where we can. I ran this branch through the usual quick manual smoke test and did not see any regressions -- data continued to flow into my elastic cloud instance.
No objections to this change going in, but also no strong opinions on which direction we should go (with a slight edit to note that @marclop's quick benchmarking is a an additional +1
for a move away from the io.Pipe
approach.
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.
Thanks for the benchmarks, Marc! I have no objections now.
I modified the PostToAPM function to accept an *http.Client
Could you add that commit to this PR?
Signed-off-by: Marc Lopez Rubio <[email protected]>
Signed-off-by: Marc Lopez Rubio <[email protected]>
Instead of using
io.Copy
, use a more straightforward compression approach. Also use a buffer pool to avoid creating a new buffer each time a request is sent.