Network performance tuning (#2608)

There is a pretty significant tradeoff between bandwidth and speed of gossipsub messages. 

We can reduce our bandwidth usage considerably at the cost of minimally delaying gossipsub messages. The impact of delaying messages has not been analyzed thoroughly yet, however this PR in conjunction with some gossipsub updates show considerable bandwidth reduction. 

This PR allows the user to set a CLI value (`network-load`) which is an integer in the range of 1 of 5 depending on their bandwidth appetite. 1 represents the least bandwidth but slowest message recieving and 5 represents the most bandwidth and fastest received message time. 

For low-bandwidth users it is likely to be more efficient to use a lower value. The default is set to 3, which currently represents a reduced bandwidth usage compared to previous version of this PR. The previous lighthouse versions are equivalent to setting the `network-load` CLI to 4.

This PR is awaiting a few gossipsub updates before we can get it into lighthouse.
This commit is contained in:
Age Manning
2022-01-14 05:42:47 +00:00
parent db95255aeb
commit 6f4102aab6
8 changed files with 120 additions and 29 deletions

View File

@@ -7,7 +7,8 @@ pub(crate) mod enr;
pub mod enr_ext;
// Allow external use of the lighthouse ENR builder
use crate::{config, metrics};
use crate::behaviour::TARGET_SUBNET_PEERS;
use crate::metrics;
use crate::{error, Enr, NetworkConfig, NetworkGlobals, Subnet, SubnetDiscovery};
use discv5::{enr::NodeId, Discv5, Discv5Event};
pub use enr::{
@@ -47,8 +48,6 @@ pub use subnet_predicate::subnet_predicate;
/// Local ENR storage filename.
pub const ENR_FILENAME: &str = "enr.dat";
/// Target number of peers we'd like to have connected to a given long-lived subnet.
pub const TARGET_SUBNET_PEERS: usize = config::MESH_N_LOW;
/// Target number of peers to search for given a grouped subnet query.
const TARGET_PEERS_FOR_GROUPED_QUERY: usize = 6;
/// Number of times to attempt a discovery request.
@@ -692,7 +691,7 @@ impl<TSpec: EthSpec> Discovery<TSpec> {
return false;
}
let target_peers = TARGET_SUBNET_PEERS - peers_on_subnet;
let target_peers = TARGET_SUBNET_PEERS.saturating_sub(peers_on_subnet);
trace!(self.log, "Discovery query started for subnet";
"subnet_query" => ?subnet_query,
"connected_peers_on_subnet" => peers_on_subnet,