Skip to content

add sync.Pool for compression writers. #7056

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

Closed
wants to merge 4 commits into from
Closed

Conversation

aryehlev
Copy link

@aryehlev aryehlev commented Jul 12, 2025

Should greatly reduce CPU and memory when using compression.
should help resolve:
#7037

Signed-off-by: Aryeh Klein aryehlevklein@gmail.com

@aryehlev aryehlev requested a review from a team as a code owner July 12, 2025 19:58
@aryehlev
Copy link
Author

#7037

@aryehlev aryehlev closed this Jul 12, 2025
@aryehlev aryehlev reopened this Jul 12, 2025
@neilalexander
Copy link
Member

Thanks for the PR, but I am not yet convinced that this is characteristic of what's going on in #7037 and this may also cause us to hold onto and reuse much larger buffers than would be needed for a future connection.

The per-client compressors are already reusing underlying buffers for the lifetime of a connection and I don't really think that it's creating the compressors that is the bulk of the issue, but rather that the latency sensitivity is too sensitive to GC pauses.

Have you done comparative benchmarking for this?

@@ -1631,8 +1632,9 @@ func (c *client) flushOutbound() bool {
}
}
if err == nil {
err = cw.Close()
err = c.out.cf(cw)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In addition to @neilalexander comments, this is wrong and would break things. The writer is reused already (hence the Reset() above). That call would invalidate it causing likely memory corruptions.

@aryehklein-rise
Copy link

@neilalexander you are right.
i initially thought it was similar issue i had in the past, but then i saw the client compressers are set once, furthermore the library uses sync pool for the exact same purpose. closing this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants