-
Couldn't load subscription status.
- Fork 1.4k
Improve fiber dump output #3192
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
Conversation
|
@adamgfraser removing [WIP] label. |
|
@adamgfraser and @simpadjo hier is the branch with the tests. https://github.com/bogdanmanate/zio/tree/pretty-dump-with-tests |
|
@bogdanmanate not sure how to do it, I'm bad at git magic. Also keep in mind that it your commit is based on commit by "evgenii", not "simpadjo" and "evgenii" didn't sign CLA. |
|
@simpadjo I think I can do this. Please give me read/write access to you fork |
Tests for dumpStr
Fix test format
|
Can you fix the failing tests? |
|
@adamgfraser I will have a look at the tests in the afternoon. |
|
@adamgfraser I think I'm done. Could you please take a look? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great.
We could potentially benefit from having an intermediate representation of the fiber dump here. Right now we go straight from having runtime fibers to generating this string. So we can't really do anything with the dump other than print it (e.g. check whether there are a certain number of children) or print it in a different way. If the fiber dump instead returned a data structure that captured this information and then we had a default way of rendering that we could support those different use cases and make it easier to refactor how the dumps get displayed in the future.
What do you think?
|
@adamgfraser yeah, totally agree |
| ) @@ sequential | ||
| ) @@ sequential, | ||
| suite("fiber dump tree")( | ||
| zio.test.test("render fiber hierarchy tree") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I call just test instead of zio.test.test I get an error:
/zio/core-tests/shared/src/test/scala/zio/FiberSpec.scala:125:7: package zio.test is not a value
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. This is an unfortunate side effect of the fact that test is both the package name and a method within the package. Fortunately this is only a problem within the zio package itself and I don't think there is a way to resolve other than renaming the package or the method, which I don't think we want to do, so we have to live with it. You handled it correctly.
|
@adamgfraser done. Although have a small problem in a test |
|
@adamgfraser could you please take a look again? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! A couple of minor comments and then let's get this merged!
| * Generates a fiber dump. | ||
| */ | ||
| final def dump: UIO[Fiber.Dump] = | ||
| final def dump(withTrace: Boolean): UIO[Fiber.Dump] = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we expect generating a dump without tracing to be a common use case? We always capture traces today and don't seem to have had any issues with that.
If we do want this as an option I would suggest we change it to:
final def dumpWith(trace: Boolean): UIO[Fiber.Dump] = ???
val dump: UIO[Fiber.Dump] =
dumpWith(true)That way we have both the flexibility and the simple dump signature for the common case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will add dumpWith to make this functionality accessible and and leave only one version in other places.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@adamgfraser done!
| */ | ||
| @silent("JavaConverters") | ||
| val dumpAll: UIO[Iterable[Dump]] = | ||
| def dumpAll(withTrace: Boolean): UIO[Iterable[Dump]] = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
|
@adamgfraser thank you! |
|
@simpadjo Thank you! That was a great idea you had about rending the fiber tree first before the tracing information. |
* Workaround breaking changes introduced in zio/zio#3192 * Revert scalaVersion change
Closes #2981
Added fiber hierarchy tree to the fiber dump output.
@bogdanmanate @adamgfraser could you please help with the testcase?
How do I create a non-trivial fiber hierarchy?
To create this output I cheated and dumped Fiber.roots.
Fiber dump output example: