-
Notifications
You must be signed in to change notification settings - Fork 390
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
Perf/randomly drop discovery bucket entry #5966
Conversation
@@ -166,25 +168,38 @@ public void ProcessNeighborsMsg(NeighborsMsg? msg) | |||
return; | |||
} | |||
|
|||
if (_isNeighborsExpected) | |||
if (_lastNeighbourSize + msg.Nodes.Length == 16) |
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 its greater than 16? Is that possible
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.
In theory. 16 is enough to fix like 99% of unexpected message though.
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 mean should it be:
if (_lastNeighbourSize + msg.Nodes.Length == 16) | |
if (_lastNeighbourSize + msg.Nodes.Length >= 16) |
The entry inside the discovery bucket tend to stay fixed and not change. And because we don't do a full dht walk, we are generally limited by the entry within the nodes from the bucket. This causes the percentage of new nodes from neighbour message to stabilize at about 10%.
This PR add a random drop when a bucket is full which causes the entry in the bucket to change. This reduces the time to reach 8000 candidate node from 40 minute to 5 without increasing the rate of neighbour request.
This is out of spec, but I guess since the density of the bucket based on the XOR distance stays the same, it should be fine. (bucket with lower distance does not get touched much as its much harder to get node to fill it).
Run is 20%, 10%, 5%, 2%, no drop, 20%, 10%, 5%, 2%, no drop.
Changes
Types of changes
What types of changes does your code introduce?
Testing
Requires testing
If yes, did you write tests?
Notes on testing
Requires documentation update
Requires explanation in Release Notes
Remarks