[ipfs/go-bitswap] Bitswap servers should reuse streams for sending responses #80
Labels
kind/enhancement
A net-new feature or improvement to an existing feature
P1
High: Likely tackled by core team if no one steps up
Problem
While sending wantlists to peers reuses streams when possible https://github.com/ipfs/go-bitswap/blob/2b51297a0b68198b6c4bcacdd8868a6df8dcd182/network/ipfs_impl.go#L105-L108
Responding to messages involves opening up new streams https://github.com/ipfs/go-bitswap/blob/2b51297a0b68198b6c4bcacdd8868a6df8dcd182/network/ipfs_impl.go#L326-L334
The main issues with this AFAICT are:
Discovered while doing some performance benchmarking in ipfs/test-plans#4.
Proposed Solution
It turns out that client side code is more than happy to continuously process multiple messages per stream
https://github.com/ipfs/go-bitswap/blob/dbfc6a1d986e18402d8301c7535a0c39b2461cb7/network/ipfs_impl.go#L406
With some basic inspection it appears the code supporting this has been around since ancient times (2016) ipfs/go-bitswap@58d1750 and so should be safe to use.
Reusing the sending stream for responses is not supported and would be a protocol breaking change and so we need two long lived streams per peer.
We should be able to reuse or copy most of the stream reuse code for the streamMessageSender used by the wantlists for sending responses. However, some care will have to be given to make sure backpressure gets happily handled when the stream is backed up so we don't pull tasks off the task queue and load blocks from disk if we have nowhere to send them.
The text was updated successfully, but these errors were encountered: