From 4d2e420366928e0b369e0ac37136da25157c208b Mon Sep 17 00:00:00 2001 From: aldenhu Date: Thu, 24 Oct 2024 21:44:42 +0000 Subject: [PATCH] admin service /threadz dumps waiting and sleeping threads on verbose=true --- crates/aptos-system-utils/src/thread_dump.rs | 66 +++++++++++--------- 1 file changed, 35 insertions(+), 31 deletions(-) diff --git a/crates/aptos-system-utils/src/thread_dump.rs b/crates/aptos-system-utils/src/thread_dump.rs index d36a746b7c171..368d2ded380d8 100644 --- a/crates/aptos-system-utils/src/thread_dump.rs +++ b/crates/aptos-system-utils/src/thread_dump.rs @@ -91,33 +91,35 @@ async fn do_thread_dump( let mut body = String::new(); for thread in trace.threads() { let frames = thread.frames(); - if !frames.is_empty() { - let symbols = frames[0].symbols(); - if !symbols.is_empty() { - if let Some(name) = symbols[0].name() { - if name.contains("epoll_wait") { - wait_threads.push(thread.name()); - continue; - } + if !verbose { + if !frames.is_empty() { + let symbols = frames[0].symbols(); + if !symbols.is_empty() { + if let Some(name) = symbols[0].name() { + if name.contains("epoll_wait") { + wait_threads.push(thread.name()); + continue; + } - if name.contains("clock_nanosleep") { - sleep_threads.push(thread.name()); - continue; + if name.contains("clock_nanosleep") { + sleep_threads.push(thread.name()); + continue; + } } } } - } - if frames.len() > 1 { - let symbols = frames[1].symbols(); - if !symbols.is_empty() { - if let Some(name) = symbols[0].name() { - if name.contains("futex_wait") - || name.contains("pthread_cond_wait") - || name.contains("pthread_cond_timedwait") - { - wait_threads.push(thread.name()); - continue; + if frames.len() > 1 { + let symbols = frames[1].symbols(); + if !symbols.is_empty() { + if let Some(name) = symbols[0].name() { + if name.contains("futex_wait") + || name.contains("pthread_cond_wait") + || name.contains("pthread_cond_timedwait") + { + wait_threads.push(thread.name()); + continue; + } } } } @@ -157,17 +159,19 @@ async fn do_thread_dump( body.push_str("\n\n"); } - body.push_str("Wait threads:"); - for wait_thread in wait_threads { - body.push_str(&format!(" {wait_thread}")); - } - body.push_str("\n\n"); + if !verbose { + body.push_str("Wait threads:"); + for wait_thread in wait_threads { + body.push_str(&format!(" {wait_thread}")); + } + body.push_str("\n\n"); - body.push_str("Sleep threads:"); - for sleep_thread in sleep_threads { - body.push_str(&format!(" {sleep_thread}")); + body.push_str("Sleep threads:"); + for sleep_thread in sleep_threads { + body.push_str(&format!(" {sleep_thread}")); + } + body.push_str("\n\n"); } - body.push_str("\n\n"); Ok(body) }