From 5211c04cb207298375f04d7487df8c19ef94fb88 Mon Sep 17 00:00:00 2001 From: Peng Zhang Date: Tue, 22 Jul 2025 14:47:56 -0700 Subject: [PATCH] Add logs for dropping alloc (#561) Summary: These logs will make it easy to tell when alloc is dropped. This information could be helpful when debugging shutdown related bugs. Reviewed By: highker Differential Revision: D78438679 --- hyperactor_mesh/src/alloc/local.rs | 10 ++++++++++ hyperactor_mesh/src/alloc/process.rs | 10 ++++++++++ hyperactor_mesh/src/alloc/remoteprocess.rs | 6 ++++++ 3 files changed, 26 insertions(+) diff --git a/hyperactor_mesh/src/alloc/local.rs b/hyperactor_mesh/src/alloc/local.rs index 11d8fed08..8a3cc841e 100644 --- a/hyperactor_mesh/src/alloc/local.rs +++ b/hyperactor_mesh/src/alloc/local.rs @@ -269,6 +269,16 @@ impl Alloc for LocalAlloc { } } +impl Drop for LocalAlloc { + fn drop(&mut self) { + tracing::debug!( + "dropping LocalAlloc of name: {}, world id: {}", + self.name, + self.world_id + ); + } +} + #[cfg(test)] mod tests { use super::*; diff --git a/hyperactor_mesh/src/alloc/process.rs b/hyperactor_mesh/src/alloc/process.rs index dc6c4b422..f691edb1e 100644 --- a/hyperactor_mesh/src/alloc/process.rs +++ b/hyperactor_mesh/src/alloc/process.rs @@ -502,6 +502,16 @@ impl Alloc for ProcessAlloc { } } +impl Drop for ProcessAlloc { + fn drop(&mut self) { + tracing::debug!( + "dropping ProcessAlloc of name: {}, world id: {}", + self.name, + self.world_id + ); + } +} + #[cfg(test)] mod tests { use super::*; diff --git a/hyperactor_mesh/src/alloc/remoteprocess.rs b/hyperactor_mesh/src/alloc/remoteprocess.rs index d1834cd06..148bb263e 100644 --- a/hyperactor_mesh/src/alloc/remoteprocess.rs +++ b/hyperactor_mesh/src/alloc/remoteprocess.rs @@ -1042,6 +1042,12 @@ impl Alloc for RemoteProcessAlloc { } } +impl Drop for RemoteProcessAlloc { + fn drop(&mut self) { + tracing::debug!("dropping RemoteProcessAlloc of world_id {}", self.world_id); + } +} + #[cfg(test)] mod test { use std::assert_matches::assert_matches;