-
Notifications
You must be signed in to change notification settings - Fork 233
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
Feat/message size #353
Feat/message size #353
Conversation
dht_net.go
Outdated
@@ -71,7 +72,7 @@ func (dht *IpfsDHT) handleNewStream(s network.Stream) { | |||
// Returns true on orderly completion of writes (so we can Close the stream). | |||
func (dht *IpfsDHT) handleNewMessage(s network.Stream) bool { | |||
ctx := dht.ctx | |||
r := ggio.NewDelimitedReader(s, network.MessageSizeMax) | |||
r := msgio.NewVarintReader(s) |
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.
You can now (after updating msgio) specify a size.
dht_net.go
Outdated
) | ||
return false | ||
} | ||
switch err := req.Unmarshal(msgbytes); err { |
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.
The EOF check applies to the ReadMsg
call.
@@ -80,14 +81,24 @@ func (dht *IpfsDHT) handleNewMessage(s network.Stream) bool { | |||
|
|||
for { | |||
var req pb.Message | |||
switch err := r.ReadMsg(&req); err { | |||
msgbytes, err := r.ReadMsg() |
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.
We need to call r.ReturnMsg
somewhere to return it to the pool when done.
related: ipfs/go-bitswap#143 |
Update msgio to latest version Use max size in msgio readers Fix error handling in reads
comments addressed @Stebalien! bumped msgio version |
Closes #346.
I thought about retrofitting the writer pool at first. Looking into the implementation of the
ggio
delimited writer, I found that the comment here was actually incorrect, and that the entire message is written to a byte buffer before being written to the underlyingWriter
. Should we discharge the pool entirely? Or is it worth simplifying the implementation to use a buffer pool and a sharedmsgio
varint writer?