-
Notifications
You must be signed in to change notification settings - Fork 737
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
IDONTWANT message optimisation to cutoff for smaller messages #6456
base: unstable
Are you sure you want to change the base?
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.
Nice, thanks for the help.
@@ -1828,8 +1825,12 @@ where | |||
peer_score.duplicated_message(propagation_source, &msg_id, &message.topic); | |||
} | |||
self.mcache.observe_duplicate(&msg_id, propagation_source); | |||
|
|||
// Broadcast IDONTWANT messages. | |||
self.send_idontwant(&raw_message, &msg_id, propagation_source); |
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 think we want this after the return, after the if statement.
At the moment, this will broadcast an IDONTWANT only if the message is a duplicate.
We want the logic to broadcast only if the message isn't a duplicate.
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.
oh yeah makes sense!
// traffic and CPU load. This acts as a lower bound cutoff for the message size to which | ||
// IDONTWANT won't be sent to peers. Only works if the peers support Gossipsub1.3 | ||
// (see https://github.com/libp2p/specs/blob/master/pubsub/gossipsub/gossipsub-v1.2.md#idontwant-message) | ||
// default is 1kb |
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.
Might be worth mentioning that the unit for the usize value is bytes.
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 always mess this up. resolved!
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.
Thanks! You need to cargo fmt
to pass the check code
CI job. The tests also need to be updated, and we should probably add another test for this case, i.e. to not send IDONTWANT when the size is inferior to the limit
@@ -2699,6 +2701,10 @@ where | |||
return; | |||
}; | |||
|
|||
if message.raw_protobuf_len() < self.config.idontwant_message_size_threshold(){ |
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 we move this check to line 1833
? So that it's explicit that we are only calling send_idontwant
if the message size is inferior to the threshold instead of having the function decide that.
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.
also the the logic was a little off. I have changed it and written passing test for the same
// Controls the message size threshold for which IDONTWANT messages are sent. | ||
// Sending IDONTWANT messages for small messages can have a negative effect to the overall | ||
// traffic and CPU load. This acts as a lower bound cutoff for the message size to which | ||
// IDONTWANT won't be sent to peers. Only works if the peers support Gossipsub1.3 | ||
// (see https://github.com/libp2p/specs/blob/master/pubsub/gossipsub/gossipsub-v1.2.md#idontwant-message) | ||
// default is 1kB |
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.
// Controls the message size threshold for which IDONTWANT messages are sent. | |
// Sending IDONTWANT messages for small messages can have a negative effect to the overall | |
// traffic and CPU load. This acts as a lower bound cutoff for the message size to which | |
// IDONTWANT won't be sent to peers. Only works if the peers support Gossipsub1.3 | |
// (see https://github.com/libp2p/specs/blob/master/pubsub/gossipsub/gossipsub-v1.2.md#idontwant-message) | |
// default is 1kB | |
// The size threshold for which IDONTWANT messages are sent. | |
// Sending IDONTWANT messages for small messages can have a negative effect to the overall | |
// traffic and CPU load. This acts as a lower bound cutoff for the message size to which | |
// IDONTWANT won't be sent to peers. Only works if the peers support Gossipsub1.2 | |
// (see https://github.com/libp2p/specs/blob/master/pubsub/gossipsub/gossipsub-v1.2.md#idontwant-message) | |
// default is 1kB |
// Controls the message size threshold for which IDONTWANT messages are sent. | ||
// Sending IDONTWANT messages for small messages can have a negative effect to the overall | ||
// traffic and CPU load. This acts as a lower bound cutoff for the message size to which | ||
// IDONTWANT won't be sent to peers. Only works if the peers support Gossipsub1.3 | ||
// (see https://github.com/libp2p/specs/blob/master/pubsub/gossipsub/gossipsub-v1.2.md#idontwant-message) | ||
// default is 1kB |
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.
// Controls the message size threshold for which IDONTWANT messages are sent. | |
// Sending IDONTWANT messages for small messages can have a negative effect to the overall | |
// traffic and CPU load. This acts as a lower bound cutoff for the message size to which | |
// IDONTWANT won't be sent to peers. Only works if the peers support Gossipsub1.3 | |
// (see https://github.com/libp2p/specs/blob/master/pubsub/gossipsub/gossipsub-v1.2.md#idontwant-message) | |
// default is 1kB | |
// The size threshold for which IDONTWANT messages are sent. | |
// Sending IDONTWANT messages for small messages can have a negative effect to the overall | |
// traffic and CPU load. This acts as a lower bound cutoff for the message size to which | |
// IDONTWANT won't be sent to peers. Only works if the peers support Gossipsub1.2 | |
// (see https://github.com/libp2p/specs/blob/master/pubsub/gossipsub/gossipsub-v1.2.md#idontwant-message) | |
// default is 1kB |
// IDONTWANT won't be sent to peers. Only works if the peers support Gossipsub1.3 | ||
// (see https://github.com/libp2p/specs/blob/master/pubsub/gossipsub/gossipsub-v1.2.md#idontwant-message) | ||
// default is 1kB | ||
pub fn idontwant_message_size_threshold(&self) -> usize{ |
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.
We would need to upstream this builder config to the lighthouse config as well https://github.com/sigp/lighthouse/blob/unstable/beacon_node/lighthouse_network/src/config.rs#L480-L502
I would also suggest adding a lighthouse cli flag to control the limit so we can test it for other feature devnets (e.g. peerdas)
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.
understood will make the requested changes and add it to a cli flag
waiting on #6436 to build the cli docs. I use a mac |
addresses #6437