-
Notifications
You must be signed in to change notification settings - Fork 112
Conversation
|
||
return pbw.WriteMsg(m.ToProtoV1()) | ||
func write(w io.Writer, m *pb.Message) error { |
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.
I wonder if we should put this in a library somewhere? I'm going to need it in the DHT.
This is showing up on the gateways. |
This ensures we don't keep large buffers allocated.
07abee7
to
70fd0fd
Compare
@Stebalien is there some context for this? |
The gateway was locking up a gigabyte in gogo readers: https://github.com/ipfs/go-bitswap/pull/143/files#diff-33bf651b39540d23d5b24eb4a54026cdL181. This patch:
Importantly, it doesn't just hang onto this buffer till the next message comes in. |
message/message.go
Outdated
if err := pb.Unmarshal(msg); err != nil { | ||
return nil, err | ||
} | ||
r.ReleaseMsg(msg) |
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.
is your enter key not working?
size := m.Size() | ||
buf := pool.Get(size + binary.MaxVarintLen64) | ||
defer pool.Put(buf) | ||
n := binary.PutUvarint(buf, uint64(size)) |
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.
what did whitespace ever do to you?
aggressively free memory This commit was moved from ipfs/go-bitswap@5628965
depends on libp2p/go-msgio#15