Skip to content

Commit

Permalink
v1.18: Disable cache warmer if RPC is not using it (backport of #1063) (
Browse files Browse the repository at this point in the history
#1068)

Disable connection cache warmer for tpu if no rpc services using it.

(cherry picked from commit d87e23d)

# Conflicts:
#	core/src/tvu.rs

* Merge conflicts

---------

Co-authored-by: Lijun Wang <83639177+lijunwangs@users.noreply.github.com>
  • Loading branch information
2 people authored and yihau committed Apr 26, 2024
1 parent 4ede51d commit b9c1382
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
27 changes: 15 additions & 12 deletions core/src/tvu.rs
Expand Up @@ -135,7 +135,7 @@ impl Tvu {
wait_to_vote_slot: Option<Slot>,
accounts_background_request_sender: AbsRequestSender,
log_messages_bytes_limit: Option<usize>,
connection_cache: &Arc<ConnectionCache>,
connection_cache: Option<&Arc<ConnectionCache>>,
prioritization_fee_cache: &Arc<PrioritizationFeeCache>,
banking_tracer: Arc<BankingTracer>,
turbine_quic_endpoint_sender: AsyncSender<(SocketAddr, Bytes)>,
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion core/src/validator.rs
Expand Up @@ -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(),
Expand Down

0 comments on commit b9c1382

Please sign in to comment.