From 47a1bd61a56610ab73e5b13e3768bc3b8b8e31c1 Mon Sep 17 00:00:00 2001 From: steviez Date: Sat, 2 Mar 2024 14:48:45 -0600 Subject: [PATCH] Rename (and disambiguate) QUIC server thread names When viewing in various tools such as gdb and perf, it is not easy to distinguish which threads are serving which function (TPU or TPU FWD) --- client/src/connection_cache.rs | 1 + core/src/tpu.rs | 2 ++ quic-client/tests/quic_client.rs | 3 +++ streamer/src/quic.rs | 26 +++++++++++++++----------- 4 files changed, 21 insertions(+), 11 deletions(-) diff --git a/client/src/connection_cache.rs b/client/src/connection_cache.rs index b53b66b155e719..a94bc7cd3d8ca8 100644 --- a/client/src/connection_cache.rs +++ b/client/src/connection_cache.rs @@ -260,6 +260,7 @@ mod tests { thread: response_recv_thread, key_updater: _, } = solana_streamer::quic::spawn_server( + "solQuicTest", "quic_streamer_test", response_recv_socket, &keypair2, diff --git a/core/src/tpu.rs b/core/src/tpu.rs index 548b299148d935..0f5431da4eb43c 100644 --- a/core/src/tpu.rs +++ b/core/src/tpu.rs @@ -153,6 +153,7 @@ impl Tpu { thread: tpu_quic_t, key_updater, } = spawn_server( + "solQuicTpu", "quic_streamer_tpu", transactions_quic_sockets, keypair, @@ -172,6 +173,7 @@ impl Tpu { thread: tpu_forwards_quic_t, key_updater: forwards_key_updater, } = spawn_server( + "solQuicTpuFwd", "quic_streamer_tpu_forwards", transactions_forwards_quic_sockets, keypair, diff --git a/quic-client/tests/quic_client.rs b/quic-client/tests/quic_client.rs index 658ee6a57d672d..0237fc21d098dc 100644 --- a/quic-client/tests/quic_client.rs +++ b/quic-client/tests/quic_client.rs @@ -72,6 +72,7 @@ mod tests { thread: t, key_updater: _, } = solana_streamer::quic::spawn_server( + "solQuicTest", "quic_streamer_test", s.try_clone().unwrap(), &keypair, @@ -212,6 +213,7 @@ mod tests { thread: request_recv_thread, key_updater: _, } = solana_streamer::quic::spawn_server( + "solQuicTest", "quic_streamer_test", request_recv_socket.try_clone().unwrap(), &keypair, @@ -239,6 +241,7 @@ mod tests { thread: response_recv_thread, key_updater: _, } = solana_streamer::quic::spawn_server( + "solQuicTest", "quic_streamer_test", response_recv_socket, &keypair2, diff --git a/streamer/src/quic.rs b/streamer/src/quic.rs index 69a75532b8ca68..a7a08c73f4833b 100644 --- a/streamer/src/quic.rs +++ b/streamer/src/quic.rs @@ -100,9 +100,9 @@ pub(crate) fn configure_server( Ok((server_config, cert_chain_pem)) } -fn rt() -> Runtime { +fn rt(name: String) -> Runtime { tokio::runtime::Builder::new_multi_thread() - .thread_name("quic-server") + .thread_name(name) .enable_all() .build() .unwrap() @@ -431,7 +431,8 @@ impl StreamStats { #[allow(clippy::too_many_arguments)] pub fn spawn_server( - name: &'static str, + thread_name: &'static str, + metrics_name: &'static str, sock: UdpSocket, keypair: &Keypair, packet_sender: Sender, @@ -443,11 +444,11 @@ pub fn spawn_server( wait_for_chunk_timeout: Duration, coalesce: Duration, ) -> Result { - let runtime = rt(); + let runtime = rt(format!("{thread_name}Rt")); let (endpoint, _stats, task) = { let _guard = runtime.enter(); crate::nonblocking::quic::spawn_server( - name, + metrics_name, sock, keypair, packet_sender, @@ -461,7 +462,7 @@ pub fn spawn_server( ) }?; let handle = thread::Builder::new() - .name("solQuicServer".into()) + .name(thread_name.into()) .spawn(move || { if let Err(e) = runtime.block_on(task) { warn!("error from runtime.block_on: {:?}", e); @@ -505,6 +506,7 @@ mod test { thread: t, key_updater: _, } = spawn_server( + "solQuicTest", "quic_streamer_test", s, &keypair, @@ -532,7 +534,7 @@ mod test { fn test_quic_timeout() { solana_logger::setup(); let (t, exit, receiver, server_address) = setup_quic_server(); - let runtime = rt(); + let runtime = rt("solQuicTestRt".to_string()); runtime.block_on(check_timeout(receiver, server_address)); exit.store(true, Ordering::Relaxed); t.join().unwrap(); @@ -543,7 +545,7 @@ mod test { solana_logger::setup(); let (t, exit, _receiver, server_address) = setup_quic_server(); - let runtime = rt(); + let runtime = rt("solQuicTestRt".to_string()); runtime.block_on(check_block_multiple_connections(server_address)); exit.store(true, Ordering::Relaxed); t.join().unwrap(); @@ -563,6 +565,7 @@ mod test { thread: t, key_updater: _, } = spawn_server( + "solQuicTest", "quic_streamer_test", s, &keypair, @@ -577,7 +580,7 @@ mod test { ) .unwrap(); - let runtime = rt(); + let runtime = rt("solQuicTestRt".to_string()); runtime.block_on(check_multiple_streams(receiver, server_address)); exit.store(true, Ordering::Relaxed); t.join().unwrap(); @@ -588,7 +591,7 @@ mod test { solana_logger::setup(); let (t, exit, receiver, server_address) = setup_quic_server(); - let runtime = rt(); + let runtime = rt("solQuicTestRt".to_string()); runtime.block_on(check_multiple_writes(receiver, server_address, None)); exit.store(true, Ordering::Relaxed); t.join().unwrap(); @@ -608,6 +611,7 @@ mod test { thread: t, key_updater: _, } = spawn_server( + "solQuicTest", "quic_streamer_test", s, &keypair, @@ -622,7 +626,7 @@ mod test { ) .unwrap(); - let runtime = rt(); + let runtime = rt("solQuicTestRt".to_string()); runtime.block_on(check_unstaked_node_connect_failure(server_address)); exit.store(true, Ordering::Relaxed); t.join().unwrap();