Skip to content

Commit a69470f

Browse files
authored
Set receive_window per quic connection (solana-labs#26936)
This change sets the receive_window for non-staked node to 1 * PACKET_DATA_SIZE, and maps the staked nodes's connection's receive_window between 1.2 * PACKET_DATA_SIZE to 10 * PACKET_DATA_SIZE based on the stakes. The changes is based on Quinn library change to support per connection receive_window tweak at the server side. quinn-rs/quinn#1393
1 parent f7c6901 commit a69470f

File tree

7 files changed

+263
-32
lines changed

7 files changed

+263
-32
lines changed

Cargo.lock

+57-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

core/src/staked_nodes_updater_service.rs

+13-4
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,15 @@ impl StakedNodesUpdaterService {
3636
let mut new_ip_to_stake = HashMap::new();
3737
let mut new_id_to_stake = HashMap::new();
3838
let mut total_stake = 0;
39+
let mut max_stake: u64 = 0;
40+
let mut min_stake: u64 = u64::MAX;
3941
if Self::try_refresh_stake_maps(
4042
&mut last_stakes,
4143
&mut new_ip_to_stake,
4244
&mut new_id_to_stake,
4345
&mut total_stake,
46+
&mut max_stake,
47+
&mut min_stake,
4448
&bank_forks,
4549
&cluster_info,
4650
) {
@@ -61,16 +65,21 @@ impl StakedNodesUpdaterService {
6165
ip_to_stake: &mut HashMap<IpAddr, u64>,
6266
id_to_stake: &mut HashMap<Pubkey, u64>,
6367
total_stake: &mut u64,
68+
max_stake: &mut u64,
69+
min_stake: &mut u64,
6470
bank_forks: &RwLock<BankForks>,
6571
cluster_info: &ClusterInfo,
6672
) -> bool {
6773
if last_stakes.elapsed() > IP_TO_STAKE_REFRESH_DURATION {
6874
let root_bank = bank_forks.read().unwrap().root_bank();
6975
let staked_nodes = root_bank.staked_nodes();
70-
*total_stake = staked_nodes
71-
.iter()
72-
.map(|(_pubkey, stake)| stake)
73-
.sum::<u64>();
76+
77+
for stake in staked_nodes.values() {
78+
*total_stake += stake;
79+
*max_stake = *stake.max(max_stake);
80+
*min_stake = *stake.min(min_stake);
81+
}
82+
7483
*id_to_stake = cluster_info
7584
.tvu_peers()
7685
.into_iter()

programs/bpf/Cargo.lock

+57-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/src/quic.rs

+12
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,15 @@ pub const QUIC_KEEP_ALIVE_MS: u64 = 1_000;
1212
// applications. Different applications vary, but most seem to
1313
// be in the 30-60 second range
1414
pub const QUIC_CONNECTION_HANDSHAKE_TIMEOUT_MS: u64 = 60_000;
15+
16+
/// The receive window for QUIC connection from unstaked nodes is
17+
/// set to this ratio times [`solana_sdk::packet::PACKET_DATA_SIZE`]
18+
pub const QUIC_UNSTAKED_RECEIVE_WINDOW_RATIO: u64 = 1;
19+
20+
/// The receive window for QUIC connection from minimum staked nodes is
21+
/// set to this ratio times [`solana_sdk::packet::PACKET_DATA_SIZE`]
22+
pub const QUIC_MIN_STAKED_RECEIVE_WINDOW_RATIO: u64 = 2;
23+
24+
/// The receive window for QUIC connection from maximum staked nodes is
25+
/// set to this ratio times [`solana_sdk::packet::PACKET_DATA_SIZE`]
26+
pub const QUIC_MAX_STAKED_RECEIVE_WINDOW_RATIO: u64 = 10;

streamer/Cargo.toml

+3-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ nix = "0.24.2"
2121
pem = "1.0.2"
2222
percentage = "0.1.0"
2323
pkcs8 = { version = "0.8.0", features = ["alloc"] }
24-
quinn = "0.8.3"
24+
quinn = {git = "https://github.com/quinn-rs/quinn.git", branch = "0.8.x", commit = "37c19743cc881cf71369946d572849d5d2ffc3fd"}
25+
quinn-proto = {git = "https://github.com/quinn-rs/quinn.git", branch = "0.8.x", commit = "37c19743cc881cf71369946d572849d5d2ffc3fd"}
26+
2527
rand = "0.7.0"
2628
rcgen = "0.9.2"
2729
rustls = { version = "0.20.6", features = ["dangerous_configuration"] }

0 commit comments

Comments
 (0)