Skip to content

Commit dbe40ec

Browse files
pzhan9meta-codesync[bot]
authored andcommitted
Add event logs (#1766)
Summary: Pull Request resolved: #1766 We have these logs for v0. This is to add the same for v1. e.g.: https://www.internalfb.com/code/fbsource/[f0a15fde560ba2afd2b1d313739489869c046c35]/fbcode/monarch/hyperactor_mesh/src/proc_mesh.rs?lines=284-291 Reviewed By: shayne-fletcher Differential Revision: D86349811 fbshipit-source-id: 4239f1d71e3d83a8e87c8c5424f3a685d03220ae
1 parent 395baba commit dbe40ec

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

hyperactor_mesh/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#![feature(impl_trait_in_bindings)]
1414
#![feature(get_disjoint_mut_helpers)]
1515
#![feature(exact_size_is_empty)]
16+
#![feature(async_fn_track_caller)]
1617

1718
pub mod actor_mesh;
1819
pub mod alloc;

hyperactor_mesh/src/v1/proc_mesh.rs

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@ use std::collections::HashMap;
1111
use std::collections::HashSet;
1212
use std::fmt;
1313
use std::ops::Deref;
14+
use std::panic::Location;
1415
use std::sync::Arc;
16+
use std::sync::OnceLock;
17+
use std::sync::atomic::AtomicUsize;
18+
use std::sync::atomic::Ordering;
1519
use std::time::Duration;
1620

1721
use hyperactor::Actor;
@@ -46,7 +50,9 @@ use ndslice::view::Region;
4650
use serde::Deserialize;
4751
use serde::Serialize;
4852
use tokio::sync::Notify;
53+
use tracing::Instrument;
4954
use tracing::Level;
55+
use tracing::span;
5056

5157
use crate::CommActor;
5258
use crate::alloc::Alloc;
@@ -282,15 +288,37 @@ impl ProcMesh {
282288
.await
283289
}
284290

291+
fn alloc_counter() -> &'static AtomicUsize {
292+
static C: OnceLock<AtomicUsize> = OnceLock::new();
293+
C.get_or_init(|| AtomicUsize::new(0))
294+
}
295+
285296
/// Allocate a new ProcMesh from the provided alloc.
286297
/// Allocate does not require an owning actor because references are not owned.
287298
#[tracing::instrument(skip_all)]
299+
#[track_caller]
288300
pub async fn allocate(
289301
cx: &impl context::Actor,
290302
mut alloc: Box<dyn Alloc + Send + Sync + 'static>,
291303
name: &str,
292304
) -> v1::Result<Self> {
293-
let running = alloc.initialize().await?;
305+
let alloc_id = Self::alloc_counter().fetch_add(1, Ordering::Relaxed) + 1;
306+
tracing::info!(
307+
name = "ProcMesh::Allocate::Attempt",
308+
alloc_id,
309+
caller = %Location::caller(),
310+
shape = ?alloc.shape(),
311+
"allocating proc mesh"
312+
);
313+
314+
let running = alloc
315+
.initialize()
316+
.instrument(span!(
317+
Level::INFO,
318+
"ProcMesh::Allocate::Initialize",
319+
alloc_id
320+
))
321+
.await?;
294322

295323
// Wire the newly created mesh into the proc, so that it is routable.
296324
// We route all of the relevant prefixes into the proc's forwarder,
@@ -308,6 +336,11 @@ impl ProcMesh {
308336
proc.clone().serve(rx);
309337
addr
310338
};
339+
tracing::info!(
340+
name = "ProcMesh::Allocate::ChannelServe",
341+
alloc_id = alloc_id,
342+
"proc started listening on addr: {proc_channel_addr}"
343+
);
311344

312345
let bind_allocated_procs = |router: &DialMailboxRouter| {
313346
// Route all of the allocated procs:

0 commit comments

Comments
 (0)