You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Basically due to our usage of "writers" in all of the encode functions, the buffer in all of these is forced to escape to the heap. (As it can't tell where the pointer to it ends, due to writer being an interface)
That's pretty cool! I didn't know you can do this so easily (escape analysis).
Even if we don't have any numbers on how beneficial it will be, it should be simple enough to change the encode function to be of the form: EncodeT(thing T) []byte (instead currently EncodeT(w io.Writer, thing T) error)
Yet this change would be breaking. Hence, I think this should be a pre-launch priority.
Do you agree @jaekwon@ebuchman ?
Are the writers in amino used to directly write to a network connection? Is that important?
In this context: protobuf uses a Buffer instead of a writer to append to the same buffer (see 1).
Basically due to our usage of "writers" in all of the encode functions, the buffer in all of these is forced to escape to the heap. (As it can't tell where the pointer to it ends, due to writer being an interface)
Run
and enjoy the interesting knowledge from the escape analysis :D
one example:
./encoder.go:39:22: buf escapes to heap
.The text was updated successfully, but these errors were encountered: