Skip to content

Commit

Permalink
Make the quic server connection table use an async lock, reducing thr…
Browse files Browse the repository at this point in the history
…ashing (solana-labs#293)

Make the quic server connection table use an async lock, reducing lock contention
  • Loading branch information
ryleung-solana authored and lijunwangs committed Apr 18, 2024
1 parent a63e7db commit 068b6d5
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions streamer/src/nonblocking/quic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,8 @@ async fn setup_connection(

match params.peer_type {
ConnectionPeerType::Staked(stake) => {
let mut connection_table_l = staked_connection_table.lock().unwrap();
let mut connection_table_l = staked_connection_table.lock().await;

if connection_table_l.total_size >= max_staked_connections {
let num_pruned =
connection_table_l.prune_random(PRUNE_RANDOM_SAMPLE_SIZE, stake);
Expand Down Expand Up @@ -547,7 +548,9 @@ async fn setup_connection(
&params,
wait_for_chunk_timeout,
stream_load_ema.clone(),
) {
)
.await
{
stats
.connection_added_from_staked_peer
.fetch_add(1, Ordering::Relaxed);
Expand All @@ -569,7 +572,9 @@ async fn setup_connection(
&params,
wait_for_chunk_timeout,
stream_load_ema.clone(),
) {
)
.await
{
stats
.connection_added_from_unstaked_peer
.fetch_add(1, Ordering::Relaxed);
Expand Down

0 comments on commit 068b6d5

Please sign in to comment.