Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepend "thread (%d)" to output from jl_print_task_backtraces() #95

Merged
merged 1 commit into from
Oct 12, 2023

Conversation

kpamnany
Copy link
Collaborator

@kpamnany kpamnany commented Oct 9, 2023

PR Description

More backtrace prepending, this time to the text output by jl_print_task_backtraces().

This should be squashed with the following commits when we upgrade:

  • 0457f8995eb49158adcab9b12d21d9d31e9e05d4
  • e015382634953445155c9fa4f51aba05235e8313
  • 8f409da5c564d8fd9e9a2d0fe19235a710fedd09

Checklist

Requirements for merging:

@github-actions github-actions bot added port-to-v1.10 This change should apply to Julia v1.10 builds port-to-master This change should apply to all future Julia builds port-to-v1.9 This change should apply to Julia v1.9 builds labels Oct 9, 2023
@NHDaly
Copy link
Member

NHDaly commented Oct 10, 2023

Can you explain the idea behind this one? Is the new jl_task_backtraces printing multithreaded? I don't see any discussion of this in the issue you link to in the PR description: JuliaLang#51056.

@NHDaly
Copy link
Member

NHDaly commented Oct 10, 2023

Or is it because you're now triggering this asynchronously, according to some conditions, and there's a chance that two threads would trigger it at the same time?

EDIT: If it's the latter, i think maybe a better solution would be to add an optional parameter for an IO object to write this output to. That way we can write each one to a buffer, and then dump the whole thing in one nice message to datadog?

(I think if you log a json line to datadog, it will make it all in one log message, rather than splitting it up. So you could print it like this:

data = String(take!(io)) # or whatever
println("""{"message":$(repr(data))}""")

and then it would be formatted much more nicely in datadog.

Copy link
Member

@NHDaly NHDaly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 The implementation here LGTM but i'm not sure i understand the purpose.

@kpamnany
Copy link
Collaborator Author

I should have explained better.

Or is it because you're now triggering this asynchronously, according to some conditions, and there's a chance that two threads would trigger it at the same time?

Because we're triggering this asynchronously, other threads are still running and could be logging things, which could result in other log messages interleaving with the backtraces. The approach we chose to address this interleaving problem was adding these prefixes. The individual task backtraces are already prefixed with thread (%d); this just adds the same prefixes to the other informational lines printed. Although there won't be much ambiguity caused by these interleavings, it just makes it a bit cleaner?

As this is in C code, using an IOBuffer would be difficult.

@kpamnany kpamnany requested a review from NHDaly October 11, 2023 19:44
@NHDaly
Copy link
Member

NHDaly commented Oct 12, 2023

Mmm yeah, you're right, i forgot about that. The C code can write to file pointers just fine, but not IOBuffers. :/
We could use a temporary file for this still though.


But okay cool thanks yeah that explanation makes sense.

@kpamnany kpamnany merged commit 3f99734 into v1.9.2+RAI Oct 12, 2023
3 checks passed
@kpamnany kpamnany deleted the kp-more-bt-prepends branch October 12, 2023 16:34
@kpamnany kpamnany removed port-to-v1.9 This change should apply to Julia v1.9 builds port-to-v1.10 This change should apply to Julia v1.10 builds labels Oct 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
port-to-master This change should apply to all future Julia builds
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants