-
Notifications
You must be signed in to change notification settings - Fork 378
feat(swip25): pull syncing optimization #5194
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
base: master
Are you sure you want to change the base?
Conversation
| } | ||
| p.logger.Debug("radius decrease", "old_radius", prevRadius, "new_radius", newRadius) | ||
| } | ||
| changed := newRadius != prevRadius |
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.
can you rename please this to something like radiusChanged or rChanged. It would be easier to figure out in the code what is this boolean all about.
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.
it is related to that the parameters for the pulling have changed that partially includes the radius change but also when a new peer is conencted to the node and that is a neighbor or a neighbor node is disconnected.
| if err != nil { | ||
| // cannot go further in the binary representation, override leaf | ||
| if t.V != nil && !bytes.Equal(t.K, key) { | ||
| panic(errShouldNeverHappen) |
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.
Do we want panics or should we use errors? Same bellow
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 tree must be used with the prerequisites defined in the errShouldNeverHappen. If there is an error, no recovery should or can happen on these special cases indicating a significant bug in the logic. in such case, it seems better to panic.
| // TreeNode is a leaf compacted binary tree | ||
| // representing the address space of the neighborhood | ||
| type TreeNode[T any] struct { | ||
| K []byte |
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.
Are there cases were we would need concurrency suport via a mutex?
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.
there is no concurrent use of TreeNode at the moment so it does not require any concurrency handling for now
| func (t *peerTreeNode) BinAssignment() (peers []*peerTreeNodeValue) { | ||
| if t.isLeaf() { | ||
| bl := uint8(len(t.V.SyncBins)) | ||
| for i := t.L; i < bl; i++ { |
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.
What if t.L > bl ?
| syncPeer.syncBins = make([]bool, p.bins) | ||
| } | ||
| if po >= newRadius { | ||
| _ = bt.Put(addr.Bytes(), &peerTreeNodeValue{SyncBins: syncPeer.syncBins}) |
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.
Why we do not have also here changed = true ?
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.
because at this point the pullsync parameters may have not changed to reinit syncings but you want to build up the tree with the neighbor peers in case there was a change in the neighborhood peerset eventually.
This SWIP describes a more efficient way to synchronise content between peers in the same neighbourhood by syncing each chunk only once.
It removed the maxPOdelta exception for syncing bins from peers below storage depth. Accordingly, bee should not allow shallow receipts on pushing chunks. That should be tackled in a different PR.
Forwarding chunks to the closest address on the network is also required since chunks will be pulled from its closest full nodes.
This is the implementation of SWIP 25 for details check the proposal.
Checklist
Description
Open API Spec Version Changes (if applicable)
Motivation and Context (Optional)
Related Issue (Optional)
Screenshots (if appropriate):