Skip to content

Commit

Permalink
Rename and uniquify QUIC thread names (#28)
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
steviez authored Mar 5, 2024
1 parent 1e133bc commit ce34f3f
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 12 deletions.
1 change: 1 addition & 0 deletions client/src/connection_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions core/src/tpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ impl Tpu {
thread: tpu_quic_t,
key_updater,
} = spawn_server(
"solQuicTpu",
"quic_streamer_tpu",
transactions_quic_sockets,
keypair,
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion quic-client/src/quic_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ lazy_static! {
static ref ASYNC_TASK_SEMAPHORE: AsyncTaskSemaphore =
AsyncTaskSemaphore::new(MAX_OUTSTANDING_TASK);
static ref RUNTIME: Runtime = tokio::runtime::Builder::new_multi_thread()
.thread_name("quic-client")
.thread_name("solQuicClientRt")
.enable_all()
.build()
.unwrap();
Expand Down
3 changes: 3 additions & 0 deletions quic-client/tests/quic_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ mod tests {
thread: t,
key_updater: _,
} = solana_streamer::quic::spawn_server(
"solQuicTest",
"quic_streamer_test",
s.try_clone().unwrap(),
&keypair,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
26 changes: 15 additions & 11 deletions streamer/src/quic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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<PacketBatch>,
Expand All @@ -443,11 +444,11 @@ pub fn spawn_server(
wait_for_chunk_timeout: Duration,
coalesce: Duration,
) -> Result<SpawnServerResult, QuicServerError> {
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,
Expand All @@ -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);
Expand Down Expand Up @@ -505,6 +506,7 @@ mod test {
thread: t,
key_updater: _,
} = spawn_server(
"solQuicTest",
"quic_streamer_test",
s,
&keypair,
Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand All @@ -563,6 +565,7 @@ mod test {
thread: t,
key_updater: _,
} = spawn_server(
"solQuicTest",
"quic_streamer_test",
s,
&keypair,
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -608,6 +611,7 @@ mod test {
thread: t,
key_updater: _,
} = spawn_server(
"solQuicTest",
"quic_streamer_test",
s,
&keypair,
Expand All @@ -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();
Expand Down

0 comments on commit ce34f3f

Please sign in to comment.