From d0cb5e273aa6b2c9bb4e8ad65c792f926d3b21df Mon Sep 17 00:00:00 2001 From: steviez Date: Wed, 6 Mar 2024 17:03:02 -0600 Subject: [PATCH] Name previously unnamed thread pool threads (#104) Several rayon and tokio threadpools did not have names; give them names to make tracking them in debug tools easier --- net-utils/src/ip_echo_server.rs | 6 +++++- runtime/src/bank.rs | 5 ++++- runtime/src/snapshot_utils/snapshot_storage_rebuilder.rs | 3 ++- validator/src/admin_rpc_service.rs | 6 +++++- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/net-utils/src/ip_echo_server.rs b/net-utils/src/ip_echo_server.rs index 7d4186ccb6a810..64fbedadc7acf9 100644 --- a/net-utils/src/ip_echo_server.rs +++ b/net-utils/src/ip_echo_server.rs @@ -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 } diff --git a/runtime/src/bank.rs b/runtime/src/bank.rs index 3ea316f857a2bc..1abf9403e3fef1 100644 --- a/runtime/src/bank.rs +++ b/runtime/src/bank.rs @@ -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", ); diff --git a/runtime/src/snapshot_utils/snapshot_storage_rebuilder.rs b/runtime/src/snapshot_utils/snapshot_storage_rebuilder.rs index 0c6116274b1cb1..30cbbd4afd5970 100644 --- a/runtime/src/snapshot_utils/snapshot_storage_rebuilder.rs +++ b/runtime/src/snapshot_utils/snapshot_storage_rebuilder.rs @@ -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") } } diff --git a/validator/src/admin_rpc_service.rs b/validator/src/admin_rpc_service.rs index 3881487882dc2e..b6d65e3ec4a4df 100644 --- a/validator/src/admin_rpc_service.rs +++ b/validator/src/admin_rpc_service.rs @@ -816,7 +816,11 @@ pub async fn connect(ledger_path: &Path) -> std::result::Result 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)]