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

Callstack visualization #1922

Merged
merged 13 commits into from
Nov 4, 2024
Merged

Callstack visualization #1922

merged 13 commits into from
Nov 4, 2024

Conversation

SouthEndMusic
Copy link
Collaborator

Fixes #1472.

@SouthEndMusic SouthEndMusic marked this pull request as draft October 30, 2024 12:12
@SouthEndMusic
Copy link
Collaborator Author

SouthEndMusic commented Oct 30, 2024

Obtaining the call graph seems to work well. We should just restrict it to smaller parts of the code, not an entire run. For visualization I went with a Makie approach, here is an example for Parameters:

image

We can debate very long about what the best way would be to visualize the data, but because it gets very dense very quickly I think this plot is best used interactively. I do think the color coding by script is quite nice.

Some other formatting ideas are:

  • Pruning non-Ribasim calls
  • Clustering by script

Copy link
Member

@evetion evetion left a comment

Choose a reason for hiding this comment

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

Great effort! 💯

Would it be useful to depend on https://graph.makie.org/stable/generated/depgraph/? The current layout seems quite constrained, ideally you have an automatic graph layout.

For interactivity, a script in utils might be a better fit? Or a new util folder in docs, so the quarto notebook is a bit shorter?

Did you test this with a single calculation timestep as well?

Finally, given your slack question, any progress on an mermaidjs translation?

docs/dev/callstacks.quarto_ipynb Outdated Show resolved Hide resolved
Project.toml Outdated Show resolved Hide resolved
@SouthEndMusic
Copy link
Collaborator Author

SouthEndMusic commented Oct 30, 2024

I feel like I'm converging towards something usable. I now sort per layer the names per script, leave out non-Ribasim calls (which can lead to floating branches because Ribasim calls can happen from non-Ribasim calls), and squash per layer calls with the same name into one.

image

And an example of water_balance!:

image

We could also make a distinction between different methods of a function, but including the signatures can get messy.

@SouthEndMusic
Copy link
Collaborator Author

Possibly all function names starting with # can be taken out, as they are not informative. I think some of them are created by @kwdef

@SouthEndMusic SouthEndMusic changed the title Callstack visualization proof of concept Callstack visualization Oct 31, 2024
@SouthEndMusic
Copy link
Collaborator Author

Improved formatting, generated functions cut out:

image

@SouthEndMusic
Copy link
Collaborator Author

SouthEndMusic commented Oct 31, 2024

The graph for a run of the allocation algorithm:

image

I also want to show allocation initialization but for some reason the call trace code crashes on that at the moment (edit: now fixed).

@SouthEndMusic SouthEndMusic marked this pull request as ready for review October 31, 2024 19:02
@SouthEndMusic
Copy link
Collaborator Author

Ah I forgot DiscreteControl

Copy link
Member

@evetion evetion left a comment

Choose a reason for hiding this comment

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

Looking good 🚀. Two remarks before we merge:

  • Maybe good to make some links from the equations/implementation page to each specific plot?
  • In the plots all the Ribasim. prefixes should be removed.

edit:
Maybe remove the spines/axes labels/ticks with hidedecorations! and/or the minimal theme.

docs/dev/callstacks.qmd Show resolved Hide resolved
xlims = (-0.4, 5.6)
)
```

Copy link
Member

Choose a reason for hiding this comment

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

Maybe add the update_cumulative_flows callback here as well? That should cover most of the core code.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I decided against adding this because update_cumulative_flows! calls very few other (Ribasim) functions.

docs/dev/callstacks.qmd Show resolved Hide resolved
@SouthEndMusic SouthEndMusic merged commit 0f703ef into main Nov 4, 2024
22 of 27 checks passed
@SouthEndMusic SouthEndMusic deleted the callstacks branch November 4, 2024 13:12
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.

Derive Julia call stacks
2 participants