Skip to content

Request & Response sync.Pool usage #390

Answered by akshayjshah
jzelinskie asked this question in Q&A
Discussion options

You must be logged in to vote

Pooling is certainly a nice optimization, but it's error-prone in this context: no matter how we structure connect-go, we'd need to be completely sure that no interceptor has retained a reference to the message or any of its sub-structures. Because pooling errors are so irritating to debug, I've always avoided exposing pooled objects across team boundaries.

I'm hopeful that arenas will be a safer route to improved overall performance.

...but impossible to pool response messages, as you do not control the lifetime of the response object.

Why not use runtime.SetFinalizer? Finalizers are somewhat distasteful and have some sharp edges, but they're a good fit for this use case. You'd still n…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@jzelinskie
Comment options

@akshayjshah
Comment options

Answer selected by akshayjshah
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
enhancement New feature or request
2 participants
Converted from issue

This discussion was converted from issue #360 on November 07, 2022 23:29.