Implement QUIC connection warmup service for future leaders (#24054)
* Increase connection timeouts * Bump quic connection cache to 1024 * Use constant for quic connection timeout and add warm cache service * Fixes to QUIC warmup service * fix check failure * fixes after rebase * fix timeout test Co-authored-by: Pankaj Garg <pankaj@solana.com>
This commit is contained in:
@ -20,10 +20,10 @@ use {
|
||||
};
|
||||
|
||||
// Should be non-zero
|
||||
static MAX_CONNECTIONS: usize = 64;
|
||||
static MAX_CONNECTIONS: usize = 1024;
|
||||
|
||||
#[derive(Clone)]
|
||||
enum Connection {
|
||||
pub enum Connection {
|
||||
Udp(Arc<UdpTpuConnection>),
|
||||
Quic(Arc<QuicTpuConnection>),
|
||||
}
|
||||
@ -117,14 +117,14 @@ impl ConnectionCacheStats {
|
||||
}
|
||||
}
|
||||
|
||||
struct ConnMap {
|
||||
struct ConnectionMap {
|
||||
map: LruCache<SocketAddr, Connection>,
|
||||
stats: Arc<ConnectionCacheStats>,
|
||||
last_stats: AtomicInterval,
|
||||
use_quic: bool,
|
||||
}
|
||||
|
||||
impl ConnMap {
|
||||
impl ConnectionMap {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
map: LruCache::new(MAX_CONNECTIONS),
|
||||
@ -140,7 +140,7 @@ impl ConnMap {
|
||||
}
|
||||
|
||||
lazy_static! {
|
||||
static ref CONNECTION_MAP: Mutex<ConnMap> = Mutex::new(ConnMap::new());
|
||||
static ref CONNECTION_MAP: Mutex<ConnectionMap> = Mutex::new(ConnectionMap::new());
|
||||
}
|
||||
|
||||
pub fn set_use_quic(use_quic: bool) {
|
||||
@ -346,6 +346,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_connection_cache() {
|
||||
solana_logger::setup();
|
||||
// Allow the test to run deterministically
|
||||
// with the same pseudorandom sequence between runs
|
||||
// and on different platforms - the cryptographic security
|
||||
|
@ -11,15 +11,20 @@ use {
|
||||
itertools::Itertools,
|
||||
lazy_static::lazy_static,
|
||||
log::*,
|
||||
quinn::{ClientConfig, Endpoint, EndpointConfig, NewConnection, WriteError},
|
||||
quinn::{
|
||||
ClientConfig, Endpoint, EndpointConfig, IdleTimeout, NewConnection, VarInt, WriteError,
|
||||
},
|
||||
quinn_proto::ConnectionStats,
|
||||
solana_sdk::{
|
||||
quic::{QUIC_MAX_CONCURRENT_STREAMS, QUIC_PORT_OFFSET},
|
||||
quic::{
|
||||
QUIC_KEEP_ALIVE_MS, QUIC_MAX_CONCURRENT_STREAMS, QUIC_MAX_TIMEOUT_MS, QUIC_PORT_OFFSET,
|
||||
},
|
||||
transport::Result as TransportResult,
|
||||
},
|
||||
std::{
|
||||
net::{SocketAddr, UdpSocket},
|
||||
sync::{atomic::Ordering, Arc},
|
||||
time::Duration,
|
||||
},
|
||||
tokio::runtime::Runtime,
|
||||
};
|
||||
@ -163,7 +168,13 @@ impl QuicClient {
|
||||
|
||||
let mut endpoint = RUNTIME.block_on(create_endpoint);
|
||||
|
||||
endpoint.set_default_client_config(ClientConfig::new(Arc::new(crypto)));
|
||||
let mut config = ClientConfig::new(Arc::new(crypto));
|
||||
let transport_config = Arc::get_mut(&mut config.transport).unwrap();
|
||||
let timeout = IdleTimeout::from(VarInt::from_u32(QUIC_MAX_TIMEOUT_MS));
|
||||
transport_config.max_idle_timeout(Some(timeout));
|
||||
transport_config.keep_alive_interval(Some(Duration::from_millis(QUIC_KEEP_ALIVE_MS)));
|
||||
|
||||
endpoint.set_default_client_config(config);
|
||||
|
||||
Self {
|
||||
endpoint,
|
||||
|
Reference in New Issue
Block a user