|
|
|
|
|
by bit_flipper
1116 days ago
|
|
Your note about encoding/gob being inefficient is somewhat accurate for how you're using it, but I want to talk a bit about how you could improve your use. encoding/gob is intended for streams, not stateless marshals/unmarshals. The first thing that is sent over the stream is the type information the receiver should expect, that's why your payload was so large. After the first type is received, subsequent messages are much smaller. You can see this by extending your example to do multiple writes; each write after the first is only 10 bytes: https://play.golang.com/p/Po_iaXrTUER You have to plan differently, but you could get large improvements to transmission sizes by changing to append only files and creating the gob encoder once per file. If you find you're creating a gob encoder/decoder very often, that's a telltale sign you're not using it as intended. |
|
However, I still keep seeing encoding/gob high up in the profiler taking a lot of time doing reflection during RPC calls.
So it does still seem like it's not ideal. Though I may still just not be understanding how to use net/rpc correctly either.