From f09d04df79f3af7da551bfec85dd91dc556dfa0a Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Thu, 25 Apr 2024 21:12:35 -0700 Subject: [PATCH] v1.18: Disable cache warmer if RPC is not using it (backport of #1063) (#1068) Disable connection cache warmer for tpu if no rpc services using it. (cherry picked from commit d87e23d8d91c32d5f2be2bb3557c730bee1e9434) # Conflicts: # core/src/tvu.rs * Merge conflicts --------- Co-authored-by: Lijun Wang <83639177+lijunwangs@users.noreply.github.com> --- core/src/tvu.rs | 27 +++++++++++++++------------ core/src/validator.rs | 2 +- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/core/src/tvu.rs b/core/src/tvu.rs index d498ab405d39aa..feaf0a9834d17c 100644 --- a/core/src/tvu.rs +++ b/core/src/tvu.rs @@ -135,7 +135,7 @@ impl Tvu { wait_to_vote_slot: Option, accounts_background_request_sender: AbsRequestSender, log_messages_bytes_limit: Option, - connection_cache: &Arc, + connection_cache: Option<&Arc>, prioritization_fee_cache: &Arc, banking_tracer: Arc, turbine_quic_endpoint_sender: AsyncSender<(SocketAddr, Bytes)>, @@ -276,16 +276,19 @@ impl Tvu { tower_storage, ); - let warm_quic_cache_service = if connection_cache.use_quic() { - Some(WarmQuicCacheService::new( - connection_cache.clone(), - cluster_info.clone(), - poh_recorder.clone(), - exit.clone(), - )) - } else { - None - }; + let warm_quic_cache_service = connection_cache.and_then(|connection_cache| { + if connection_cache.use_quic() { + Some(WarmQuicCacheService::new( + connection_cache.clone(), + cluster_info.clone(), + poh_recorder.clone(), + exit.clone(), + )) + } else { + None + } + }); + let (cost_update_sender, cost_update_receiver) = unbounded(); let cost_update_service = CostUpdateService::new(blockstore.clone(), cost_update_receiver); @@ -498,7 +501,7 @@ pub mod tests { None, AbsRequestSender::default(), None, - &Arc::new(ConnectionCache::new("connection_cache_test")), + Some(&Arc::new(ConnectionCache::new("connection_cache_test"))), &ignored_prioritization_fee_cache, BankingTracer::new_disabled(), turbine_quic_endpoint_sender, diff --git a/core/src/validator.rs b/core/src/validator.rs index f725b166100bdd..6d2a9fb47af9ca 100644 --- a/core/src/validator.rs +++ b/core/src/validator.rs @@ -1306,7 +1306,7 @@ impl Validator { config.wait_to_vote_slot, accounts_background_request_sender, config.runtime_config.log_messages_bytes_limit, - &connection_cache, + json_rpc_service.is_some().then_some(&connection_cache), // for the cache warmer only used for STS for RPC service &prioritization_fee_cache, banking_tracer.clone(), turbine_quic_endpoint_sender.clone(),