Skip to content

Commit

Permalink
Name previously unnamed thread pool threads (anza-xyz#104)
Browse files Browse the repository at this point in the history
Several rayon and tokio threadpools did not have names; give them names
to make tracking them in debug tools easier
  • Loading branch information
steviez authored and willhickey committed Mar 9, 2024
1 parent 54b44a3 commit d0cb5e2
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
6 changes: 5 additions & 1 deletion net-utils/src/ip_echo_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,11 @@ pub fn ip_echo_server(
) -> IpEchoServer {
tcp_listener.set_nonblocking(true).unwrap();

let runtime = Runtime::new().expect("Failed to create Runtime");
let runtime = tokio::runtime::Builder::new_multi_thread()
.thread_name("solIpEchoSrvrRt")
.enable_all()
.build()
.expect("new tokio runtime");
runtime.spawn(run_echo_server(tcp_listener, shred_version));
runtime
}
5 changes: 4 additions & 1 deletion runtime/src/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1483,7 +1483,10 @@ impl Bank {
let epoch = self.epoch();
let slot = self.slot();
let (thread_pool, thread_pool_time) = measure!(
ThreadPoolBuilder::new().build().unwrap(),
ThreadPoolBuilder::new()
.thread_name(|i| format!("solBnkNewEpch{i:02}"))
.build()
.expect("new rayon threadpool"),
"thread_pool_creation",
);

Expand Down
3 changes: 2 additions & 1 deletion runtime/src/snapshot_utils/snapshot_storage_rebuilder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -418,9 +418,10 @@ impl SnapshotStorageRebuilder {
/// Builds thread pool to rebuild with
fn build_thread_pool(&self) -> ThreadPool {
ThreadPoolBuilder::default()
.thread_name(|i| format!("solRbuildSnap{i:02}"))
.num_threads(self.num_threads)
.build()
.unwrap()
.expect("new rayon threadpool")
}
}

Expand Down
6 changes: 5 additions & 1 deletion validator/src/admin_rpc_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,11 @@ pub async fn connect(ledger_path: &Path) -> std::result::Result<gen_client::Clie
}

pub fn runtime() -> Runtime {
Runtime::new().expect("new tokio runtime")
tokio::runtime::Builder::new_multi_thread()
.thread_name("solAdminRpcRt")
.enable_all()
.build()
.expect("new tokio runtime")
}

#[derive(Default, Deserialize, Clone)]
Expand Down

0 comments on commit d0cb5e2

Please sign in to comment.