bitswap: Bitswap now sends multiple blocks per message#5
bitswap: Bitswap now sends multiple blocks per message#5Stebalien merged 2 commits intoipfs:masterfrom
Conversation
|
Hey @taylormike, sorry for the wait. New repos mean i wasnt watching for notifications. |
decision/engine.go
Outdated
| newWorkExists = true | ||
| if blockSize, _ = e.bs.GetSize(entry.Cid); blockSize == -1 { | ||
| // Force Update Size Cache | ||
| e.bs.Get(entry.Cid) |
There was a problem hiding this comment.
This really shouldn't be necessary. GetSize should always work (even if it isn't cached).
There was a problem hiding this comment.
@Stebalien I agree, I removed the 'GetSize, then Get, then GetSize sequence'
This is done. I pushed out these changes and squashed into a single commit.
| activeEntries = []*wl.Entry{} | ||
| msgSize = 0 | ||
| } | ||
| activeEntries = append(activeEntries, entry.Entry) |
There was a problem hiding this comment.
Shouldn't this be in an else condition?
There was a problem hiding this comment.
This is intentional.
That being said, I can rewrite it as such:
if msgSize + blockSize < maxMessageSize {
activeEntries = append(activeEntries, entry.Entry)
msgSize += blockSize
} else {
e.peerRequestQueue.Push(p, activeEntries...)
activeEntries = []*wl.Entry{}
msgSize = 0
}
decision/peer_request_queue.go
Outdated
|
|
||
| // Push currently adds a new peerRequestTask to the end of the list | ||
| func (tl *prq) Push(entry *wantlist.Entry, to peer.ID) { | ||
| func (tl *prq) Push(entries []*wantlist.Entry, to peer.ID) { |
There was a problem hiding this comment.
API nit: While we're changing this, I'd change it to Push(to peer.ID, entries ...*wantlist.Entry).
There was a problem hiding this comment.
@Stebalien I agree.
This is done. I pushed out these changes and squashed into a single commit.
schomatis
left a comment
There was a problem hiding this comment.
Very clean, nice. The message size logic seems OK. (I'm not familiarized with the rest of the code.)
decision/engine.go
Outdated
| l.wantList = wl.New() | ||
| } | ||
|
|
||
| blockSize, msgSize := 0, 0 |
There was a problem hiding this comment.
cleaner to write:
var blockSize, msgSize int
There was a problem hiding this comment.
@whyrusleeping I agree.
This is done. I pushed out these changes and squashed into a single commit.
decision/engine.go
Outdated
| if exists, err := e.bs.Has(entry.Cid); err == nil && exists { | ||
| e.peerRequestQueue.Push(entry.Entry, p) | ||
| newWorkExists = true | ||
| if blockSize, _ = e.bs.GetSize(entry.Cid); blockSize == -1 { |
There was a problem hiding this comment.
I wouldnt throw away an error. If this actually errors, something seems pretty wrong. It's worthy of logging IMO
There was a problem hiding this comment.
There was a previous mention from @Stebalien that GetSize wouldn't fail, but maybe we could add a comment there explaining it, since yes, that silent error seems suspicious.
This really shouldn't be necessary. GetSize should always work (even if it isn't cached).
There was a problem hiding this comment.
Sorry, that statement was a bit confusing. I meant that if the Get worked, the GetSize should have worked. That is, we can just call:
size, err := e.bs.GetSize(entry.Cid)
if err != nil {
/* we don't have it, *may* be an error, check if it's bs.ErrNotFound */
} else {
// we have the block
}We don't need to call GetSize, then Get, then GetSize.
There was a problem hiding this comment.
@whyrusleeping, @schomatis, @schomatis I agree.
I removed the 'GetSize, then Get, then GetSize sequence' and I'm now logging the error.
This is done. I pushed out these changes and squashed into a single commit.
d501754 to
433f52e
Compare
|
I pushed out the most recent code review feedback changes and squashed into a single commit. |
There was a problem hiding this comment.
One small performance nit and one slightly larger concern.
When testing this, it didn't appear to have much impact until I upped the fetch concurrency quite a bit. However, I've been wanting to do that for a while anyways. Once I did that, I noticed a ~20% speedup (not counting the speedup from the increased parallelism).
Also, I wasn't able to test in a real system. I expect this'll have quite a bit more impact on a network with many peers.
decision/engine.go
Outdated
| if exists, err := e.bs.Has(entry.Cid); err == nil && exists { | ||
| e.peerRequestQueue.Push(entry.Entry, p) | ||
| newWorkExists = true | ||
| if blockSize, err = e.bs.GetSize(entry.Cid); err != nil { |
There was a problem hiding this comment.
Actually, we should probably just use GetSize instead of Has. That way, we only make one request.
There was a problem hiding this comment.
(that is, we can replace the Has check in the condition)
There was a problem hiding this comment.
@Stebalien
I agree, I pushed out this change and squashed into a single commit.
decision/peer_request_queue.go
Outdated
| func taskKey(p peer.ID, k *cid.Cid) string { | ||
| func taskKey(p peer.ID, entries []*wantlist.Entry) string { | ||
| key := string(p) | ||
| for _, entry := range entries { |
There was a problem hiding this comment.
This is a bit unfortunate as it could grow quite large (very large). I wonder if we can switch to a different method for computing task keys.
There was a problem hiding this comment.
Ah, I see. This isn't actually used. Mind removing it along with the Key() function?
There was a problem hiding this comment.
@Stebalien Sorry for the delayed response.
This is done. I pushed out this change and squashed into a single commit.
|
I've tested this against go-ipfs and it doesn't appear to break anything. |
|
It looks like the checkHandledInOrder test is broken. |
|
@Stebalien I'm looking into the checkHandledInOrder test failure. |
433f52e to
bd8c0f4
Compare
|
@Stebalien Sorry for the delayed response. |
Updated PeerRequestTask to hold multiple wantlist.Entry(s). This allows Bitswap to send multiple blocks in bulk per a Peer's request. Also, added a metric for how many blocks to put in a given message. Currently: 512 * 1024 bytes. License: MIT Signed-off-by: Jeromy <why@ipfs.io>
bd8c0f4 to
eb0d1ff
Compare
fixes bs.GetSize bug
|
Running the go-ipfs sharness tests now. |
|
Looks good! |
…dmultiple bitswap: Bitswap now sends multiple blocks per message This commit was moved from ipfs/go-bitswap@cbd7eb7
Updated PeerRequestTask to hold multiple wantlist.Entry(s). This allows Bitswap to send multiple blocks in bulk per a Peer's request. Also, added a metric for how many blocks to put in a given message. Currently: 512 * 1024 bytes.
Fixes #4378
@whyrusleeping @Stebalien