-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Introduce coroutine dump format for better visualisation of structured concurrency #3587
Comments
Your question looks like a false dichotomy. In your example, |
Thank you for your comment! That’s true, just improving text format of the dump is a possible option. Do you have any suggestions on what may make the text format more readable and convenient for troubleshooting? |
The main (ignored) issue for me is the duplication on a large dump. See this trivial example:
Collapsing coroutines with the same stack is really useful, the dump is shorter and more readable.
Other issues regarding the size of the dump: is it a good idea to dump some megabytes of data into the log file? |
From https://openjdk.org/jeps/425:
Maybe it makes sense to look at what |
For now, For example, here is the structured thread dump: root
|
Introduction
Currently
kotlinx-coroutines-debug
provides the following API for dumping coroutines:DebugProbes.dumpCoroutines
prints all active coroutines, including their state, creation and suspension stacktraces. Though the output of this method is similar tojstack
, it only presents a flat list of coroutines, that is rather difficult to analyse in case of a large number of coroutines.DebugProbes.dumpCoroutinesInfo
provides a list of objects with information about active coroutines.DebugProbes.printJob
/DebugProbes.printScope
prints isolated parts of coroutines hierarchy referenced by aJob
orCoroutineScope
instances. Though these methods can not provide suspension stacktrace.For now, there is no coroutine dump that would group coroutines in a meaningful way visualising relationships of structured concurrency and providing a stack trace. This proposal aims to come up with a more suitable dump format.
Proposed solution:
DebugProbes.dumpCoroutines
can provide coroutine dump in JSON format in addition to plain text:DebugProbes.dumpCoroutines(System.out, CoroutineDumpFormat.JSON)
Pros:
Cons:
Possible alternatives:
Plain text + indents
We can still print coroutine dump as a plain text, but coroutines may be sorted by their parent and indents will show their relationships.
Example output:
Pros:
The text was updated successfully, but these errors were encountered: