Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@simpadjo
Copy link
Contributor

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:

Screenshot from 2020-03-22 15-38-02

@CLAassistant
Copy link

CLAassistant commented Mar 22, 2020

CLA assistant check
All committers have signed the CLA.

@simpadjo simpadjo changed the title WIP: Improve fiber dump output Improve fiber dump output Mar 22, 2020
@simpadjo
Copy link
Contributor Author

@adamgfraser removing [WIP] label.
@bogdanmanate created couple of testcases, I think they could be added as a follow-up PR.

@bogdanmanate
Copy link
Contributor

@adamgfraser and @simpadjo hier is the branch with the tests. https://github.com/bogdanmanate/zio/tree/pretty-dump-with-tests
Maybe we should merge it to this PR. What do you think ?

@simpadjo
Copy link
Contributor Author

@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.

@bogdanmanate
Copy link
Contributor

@simpadjo I think I can do this. Please give me read/write access to you fork

@adamgfraser
Copy link
Contributor

Can you fix the failing tests?

@bogdanmanate
Copy link
Contributor

@adamgfraser I will have a look at the tests in the afternoon.

@simpadjo
Copy link
Contributor Author

@adamgfraser I think I'm done. Could you please take a look?

Screenshot from 2020-03-26 22-29-24

Copy link
Contributor

@adamgfraser adamgfraser left a 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?

@simpadjo
Copy link
Contributor Author

@adamgfraser yeah, totally agree

) @@ sequential
) @@ sequential,
suite("fiber dump tree")(
zio.test.test("render fiber hierarchy tree") {
Copy link
Contributor Author

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

Copy link
Contributor

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.

@simpadjo
Copy link
Contributor Author

@adamgfraser done. Although have a small problem in a test

@simpadjo
Copy link
Contributor Author

simpadjo commented Apr 1, 2020

@adamgfraser could you please take a look again?

Copy link
Contributor

@adamgfraser adamgfraser left a 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] =
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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]] =
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment as above.

@simpadjo simpadjo requested a review from adamgfraser April 2, 2020 11:53
Copy link
Contributor

@adamgfraser adamgfraser left a comment

Choose a reason for hiding this comment

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

Looks great!

@adamgfraser adamgfraser merged commit f564c53 into zio:master Apr 2, 2020
@simpadjo
Copy link
Contributor Author

simpadjo commented Apr 2, 2020

@adamgfraser thank you!

@adamgfraser
Copy link
Contributor

@simpadjo Thank you! That was a great idea you had about rending the fiber tree first before the tracing information.

@simpadjo simpadjo deleted the pretty-dump branch May 17, 2020 17:22
vpavkin added a commit to vpavkin/zio-zmx that referenced this pull request May 29, 2020
softinio pushed a commit to zio-archive/zio-zmx that referenced this pull request May 31, 2020
* Workaround breaking changes introduced in zio/zio#3192

* Revert scalaVersion change
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ZIO Core: Improve Rendering of Fiber Dumps

4 participants