Skip to content

Commit

Permalink
admin service /threadz dumps waiting and sleeping threads on verbose=…
Browse files Browse the repository at this point in the history
…true (#15077)
  • Loading branch information
msmouse authored Oct 25, 2024
1 parent c070f4c commit cd49e1c
Showing 1 changed file with 35 additions and 31 deletions.
66 changes: 35 additions & 31 deletions crates/aptos-system-utils/src/thread_dump.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
}
Expand Down Expand Up @@ -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)
}

0 comments on commit cd49e1c

Please sign in to comment.