Skip to content
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

Go - reuse buffers #85

Closed
newtack opened this issue Sep 26, 2014 · 8 comments
Closed

Go - reuse buffers #85

newtack opened this issue Sep 26, 2014 · 8 comments

Comments

@newtack
Copy link

newtack commented Sep 26, 2014

With Go being garbage collected, it is a bad idea to constantly create byte buffers from scratch.

Rather than creating new buffers, there should be a mechanism to reuse buffers.

A simple way to do so is to expose public variables of type func that are used for buffer creation, and if possible also a variable of type func that releases the buffer (back into the pool).

The default assignments to the variables can use the existing implementation (create buffer from scratch), but any client that wishes to override the variable with a function that uses a buffer pool.

@newtack
Copy link
Author

newtack commented Sep 28, 2014

There is another option to solve the original problem of avoiding too much garbage collection: The ability to reuse a builder for other serializations. To do this, there would need to be a way re-initialize the internals, without re-creating objects, e.g. clearing the vtables without removing the allocated capacity.

@rw
Copy link
Collaborator

rw commented Sep 30, 2014

I am strongly in favor of something like this. Would you like to to try making a pull request?

@ghost
Copy link

ghost commented Sep 30, 2014

Yeah, the C++ buffers are already reusable, see FlatBufferBuilder::Clear().

@cbandy
Copy link

cbandy commented Apr 5, 2015

It looks like #165 has code for this.

@erikdubbelboer
Copy link

Since #165 is merged can't this issue be closed?

@ghost
Copy link

ghost commented Aug 10, 2015

Looks like it.. @rw ?

@rw
Copy link
Collaborator

rw commented Aug 10, 2015

Yeah, Reset seems to make this unneeded.
On Aug 10, 2015 19:22, "Wouter van Oortmerssen" notifications@github.com
wrote:

Looks like it.. @rw https://github.com/rw ?


Reply to this email directly or view it on GitHub
#85 (comment).

@rw
Copy link
Collaborator

rw commented Aug 20, 2015

Closing since this is fixed by #165.

@rw rw closed this as completed Aug 20, 2015
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

No branches or pull requests

4 participants