-
Notifications
You must be signed in to change notification settings - Fork 112
Bitswap Refactor #4: Extract session peer manager from sessions #26
Conversation
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 understand a fair amount of this is just shuffling code around but I figure if it's being moved around it can get freshened up as well.
On top of the comments made, could all the exported types and functions/methods get a godoc comment, please?
messagequeue/messagequeue.go
Outdated
func (mq *msgQueue) openSender(ctx context.Context) error { | ||
// allow ten minutes for connections this includes looking them up in the | ||
// dht dialing them, and handshaking | ||
conctx, cancel := context.WithTimeout(ctx, time.Minute*10) |
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 timeout value could potentially be a configuration field of the msgQueue
struct? Not sure though
messagequeue/messagequeue.go
Outdated
return mq.refcnt > 0 | ||
} | ||
|
||
func (mq *msgQueue) AddMessage(entries []*bsmsg.Entry, ses uint64) { |
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.
ses
?
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.
session id. I don't make the variable names, I just copy-paste them. :)
But good point and I'll work on some variable names too -- just one at a time.
18e67bc
to
4d5134c
Compare
90995eb
to
a616ddb
Compare
744f9e4
to
b6787e8
Compare
@lanzafame @whyrusleeping @michaelavila @eingenito @djdv I believe this PR to be done and would love any feedback you have. FYI, much has changed since the last round of feedback. Seeking 2 solid LGTMs before merge. |
we've been hearing a bunch of feedback about bitswap performance from folks using ipfs in production, would love to see this merged so performance work can happen on top of it! |
This PR is exceedingly large, which makes review quite difficult. I would not feel comfortable pushing this through without proper review (especially since there are structural changes to core components) |
@djdv I've assigned you to review this as you're also working on bitswap performance. However, if you're swamped, we can find someone else. |
I appreciate the feedback about the size of the PR. That's fair I will write up an explanation tomorrow of some design decisions and also do some line by line commenting. I can also do a video screencast to go over it. To be clear, while there are a number of changes, my belief is there is only one potential "breaking change" (SessionsForBlock was technically a public bitswap method, even though it's not actually used publicly as far as I know, certainly not in go-ipfs), and only a few changes that go beyond moving code around and restructuring. |
@hannahhoward I think this would be much easier if it were many smaller PRs. Each of the individual changes made here could be PRed as they happen, giant sweeping 'refactor' PRs are a great way for bugs to sneak in, especially when the author insists they are 'just moving stuff around'. For example, the previous |
@whyrusleeping it's actually not to late to seperate into separate PRs, and I think that's a reasonable idea. The commit history is fairly linear and most commits have passing tests, so I think that's a reasonable change. |
@hannahhoward awesome! |
@djdv @whyrusleeping @Stebalien @lanzafame @eingenito @michaelavila I get it -- 20+ fully modified files is a lot to digest, and hard to follow the progress and thinking of. I've seperated this into 4 seperate PRs. The first I am hoping we can merge fairly quickly, as it only covers what several people have already commented on (plus some fixes for those comments, and the remaining issues are addressed in subsequent PRs): The next is the seperate of the want manager and peer manager, plus unit tests and further cleanup: The 3rd is just extracting sessions to a package: And finally there this PR, which is now just extracting the session peer manager from sessions itself, plus remaining unit tests. I've set the base of the PR for each branch to the previous branch, and will change the base to master as we merge. |
5eb506e
to
604ae5e
Compare
b6787e8
to
106b96f
Compare
took the liberty to rename this PR for consistency and clarity thank you for putting in the work to make these changes easier to review 💯 |
604ae5e
to
40aa1fb
Compare
extract the job of finding and managing peers for a session from the job of requesting blocks
Add a unit test and do some additional decoupling
Add unit test for sessionpeermanger and comment exported methods
Add a unit test for session package
106b96f
to
e43c4b8
Compare
e43c4b8
to
0666ee8
Compare
0666ee8
to
16f00de
Compare
@Stebalien @whyrusleeping @lanzafame @eingenito @michaelavila I know you all already took a look at this one when it was a giant blob, but it's ready to review on it's own as the final PR in this refactor sequence. |
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.
Ignore my comments - they were existing code and no need to change.
out := cq.elems[0] | ||
cq.elems = cq.elems[1:] | ||
|
||
if cq.eset.Has(out) { |
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.
This doesn't really matter - but I think Remove no-ops if the target doesn't exist - so might not need the Has call. Totally not something that has to be changed.
} | ||
|
||
func (cq *cidQueue) Len() int { | ||
return cq.eset.Len() |
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.
This also totally doesn't matter but you'll Pop() if something is in the set or not - maybe you should take the length of elems?
Merging on account of it's been open several days and @eingenito reviewing in depth |
Bitswap Refactor ipfs#4: Extract session peer manager from sessions This commit was moved from ipfs/go-bitswap@4fc6272
Goals
Modularize Bitswap in preparation for attempts to optimize bitswap further
This also gets us quite a bit of the way toward the proposed split of bitswap into low level "just ask for blocks from peers and respond to requests" bitswap and high level bitswap -- sessions, and possibly other drivers as time goes on.
Implementation
Final PR includes:
For discussion
child of ipfs/kubo#5723