Skip to content

Commit

Permalink
Add option to jl_print_task_backtraces(bool) to control whether or …
Browse files Browse the repository at this point in the history
…not to print DONE tasks (#47933)

Add option to `jl_print_task_backtraces(bool)` to control whether or not to print DONE tasks

This lets you print all live tasks, with less noise in the logs, in case
it's been a while since the last GC.

In some cases, we are seeing many thousands of DONE Tasks, which greatly
increase the noise in the logs, and can overwhelm the DataDog logging.

The API now takes a bool, which can allow us to control this setting, letting us print
the DONE tasks if the user wants to, but also hide them if desired.
  • Loading branch information
NHDaly committed Dec 28, 2022
1 parent 6ea5ad5 commit 8324512
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/stackwalk.c
Original file line number Diff line number Diff line change
Expand Up @@ -1126,7 +1126,7 @@ JL_DLLEXPORT void jl_print_backtrace(void) JL_NOTSAFEPOINT
// Print backtraces for all live tasks, for all threads.
// WARNING: this is dangerous and can crash if used outside of gdb, if
// all of Julia's threads are not stopped!
JL_DLLEXPORT void jl_print_task_backtraces(void) JL_NOTSAFEPOINT
JL_DLLEXPORT void jl_print_task_backtraces(int show_done) JL_NOTSAFEPOINT
{
size_t nthreads = jl_atomic_load_acquire(&jl_n_threads);
jl_ptls_t *allstates = jl_atomic_load_relaxed(&jl_all_tls_states);
Expand All @@ -1146,9 +1146,13 @@ JL_DLLEXPORT void jl_print_task_backtraces(void) JL_NOTSAFEPOINT
void **lst = live_tasks->items;
for (size_t j = 0; j < live_tasks->len; j++) {
jl_task_t *t = (jl_task_t *)lst[j];
int t_state = jl_atomic_load_relaxed(&t->_state);
if (!show_done && t_state == JL_TASK_STATE_DONE) {
continue;
}
jl_safe_printf(" ---- Task %zu (%p)\n", j + 1, t);
jl_safe_printf(" (sticky: %d, started: %d, state: %d, tid: %d)\n",
t->sticky, t->started, jl_atomic_load_relaxed(&t->_state),
t->sticky, t->started, t_state,
jl_atomic_load_relaxed(&t->tid) + 1);
if (t->stkbuf != NULL)
jlbacktracet(t);
Expand Down

0 comments on commit 8324512

Please sign in to comment.