Skip to content

Commit abdea9b

Browse files
pzhan9meta-codesync[bot]
authored andcommitted
assign thread name to the runtime dedicated to python tasks (#1743)
Summary: Pull Request resolved: #1743 We log thread names in scuba. It is helpful to assign special thread names for the tokio runtime dedicated to python tasks. Reviewed By: dulinriley Differential Revision: D86053208 fbshipit-source-id: bb733b599a04e127c58b5fa423595a9ac8af7961
1 parent f40f6db commit abdea9b

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

monarch_hyperactor/src/runtime.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ use std::future::Future;
1111
use std::pin::Pin;
1212
use std::sync::RwLock;
1313
use std::sync::RwLockReadGuard;
14+
use std::sync::atomic::AtomicUsize;
15+
use std::sync::atomic::Ordering;
1416
use std::time::Duration;
1517

1618
use anyhow::Result;
@@ -47,6 +49,11 @@ pub fn get_tokio_runtime<'l>() -> std::sync::MappedRwLockReadGuard<'l, tokio::ru
4749
if write_guard.is_none() {
4850
*write_guard = Some(
4951
tokio::runtime::Builder::new_multi_thread()
52+
.thread_name_fn(|| {
53+
static ATOMIC_ID: AtomicUsize = AtomicUsize::new(0);
54+
let id = ATOMIC_ID.fetch_add(1, Ordering::SeqCst);
55+
format!("monarch-pytokio-worker-{}", id)
56+
})
5057
.enable_all()
5158
.build()
5259
.unwrap(),

0 commit comments

Comments
 (0)