Skip to content

Commit

Permalink
Treat super low staked with QOS of unstaked
Browse files Browse the repository at this point in the history
  • Loading branch information
lijunwangs committed Apr 10, 2024
1 parent 72ee270 commit 90921d3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 10 additions & 2 deletions streamer/src/nonblocking/quic.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use {
crate::{
nonblocking::stream_throttle::{
ConnectionStreamCounter, StakedStreamLoadEMA, STREAM_STOP_CODE_THROTTLING,
ConnectionStreamCounter, StakedStreamLoadEMA, MAX_STREAMS_PER_MS,
STREAM_STOP_CODE_THROTTLING,
},
quic::{configure_server, QuicServerError, StreamStats},
streamer::StakedNodes,
Expand Down Expand Up @@ -501,7 +502,14 @@ async fn setup_connection(
),
|(pubkey, stake, total_stake, max_stake, min_stake)| {
let peer_type = if stake > 0 {
ConnectionPeerType::Staked(stake)
// If it is a staked connection with ultra low stake ratio, treat it as unstaked.
let min_ratio = 1_f64 / (MAX_STREAMS_PER_MS * 100) as f64;
let stake_ratio = stake as f64 / total_stake as f64;
if stake_ratio < min_ratio {
ConnectionPeerType::Unstaked
} else {
ConnectionPeerType::Staked(stake)
}
} else {
ConnectionPeerType::Unstaked
};
Expand Down
2 changes: 1 addition & 1 deletion streamer/src/nonblocking/stream_throttle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use {
};

/// Limit to 250K PPS
const MAX_STREAMS_PER_MS: u64 = 250;
pub const MAX_STREAMS_PER_MS: u64 = 250;
const MAX_UNSTAKED_STREAMS_PERCENT: u64 = 20;
const STREAM_THROTTLING_INTERVAL_MS: u64 = 100;
pub const STREAM_STOP_CODE_THROTTLING: u32 = 15;
Expand Down

0 comments on commit 90921d3

Please sign in to comment.