-
Notifications
You must be signed in to change notification settings - Fork 13
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
Use buffer pools for JsonSerializationWriter #81
Conversation
Thanks for the additional contribution @eric-millin. Out of curiosity, why not push that to the original PR? Also expect some delays in reviews, most of the team is based in Kenya and they've had a couple of national holidays recently. |
I thought about it and can do, if you prefer. In my mind the change to the semantics of But y'all's the boss, so happy to combine them if it makes life easier. |
Thanks for the context, we don't want you to have to do additional work, this is fine, we'll review this one once the other one is merged. |
Lmk if you change your mind. It's just a matter of |
This pull request has conflicting changes, the author must resolve the conflicts before this pull request can be merged. |
@eric-millin, would you mind rebasing and handling the conflicts please? |
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 this contribution :-). Please resolve differenced and we should be good to go
4cc3635
to
eaebbef
Compare
Done |
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 contribution. @rkodev for final review
This reverts commit b68e8c5.
This PR depends on #79
Creating and garbage collecting buffers is expensive and can have a significant impact in scenarios with high concurrency. This change improves serialization performance by utilizing a buffer pool.
I also made the
Close
semantics more idiomatic by making it a true finalizer. The existing behavior is what most Go packages would wrap in aReset
function. The current behavior is counterintuitive because I typically wouldn’t expect to reuse a struct after I had calledClose
on it.The existing
Close
implementation also has the disadvantage of allocating a new buffer even when there is no intent to reuse the writer. If a user is always callingClose
before disposing the writer, they’re unwittingly hurting performance by doubling buffer allocations and increasing the effort required to clean them up.Same benchmark as #79