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

Feat/message size #353

Merged
merged 3 commits into from Jun 18, 2019
Merged

Feat/message size #353

merged 3 commits into from Jun 18, 2019

Conversation

bigs
Copy link
Contributor

@bigs bigs commented Jun 17, 2019

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 underlying Writer. Should we discharge the pool entirely? Or is it worth simplifying the implementation to use a buffer pool and a shared msgio varint writer?

@bigs bigs requested review from raulk and Kubuxu June 17, 2019 22:45
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)
Copy link
Member

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 {
Copy link
Member

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()
Copy link
Member

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.

@Stebalien
Copy link
Member

related: ipfs/go-bitswap#143

Update msgio to latest version
Use max size in msgio readers
Fix error handling in reads
@bigs
Copy link
Contributor Author

bigs commented Jun 18, 2019

comments addressed @Stebalien! bumped msgio version

@Stebalien Stebalien merged commit 874e3d3 into master Jun 18, 2019
@Stebalien Stebalien deleted the feat/message-size branch June 18, 2019 16:03
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

Successfully merging this pull request may close these issues.

DHT allocates 4MB per message
2 participants