dump: Handle cycles in graphviz#1978
Open
deepseafishy wants to merge 6 commits intonamhyung:masterfrom
Open
Conversation
Identify if the current graph entry must be skipped druing `dump`, which is done during the add_graph_entry() procedure. Basic idea is to find recursive calls, but the first recursive call cannot be skipped. For example, if the call trace shows: main - fib - fib - fib then the first (fib - fib) must be present but the second must be skipped, making the graph look like: main - fib - fib To separate recursive calls from the first recursive call, determine if the node's name is the same with curr and additionally check if curr->parent's name is the same as well. Signed-off-by: Daon Park <deeopark39@gmail.com>
If a node is skipped due to being a recursive call, then it's nr_calls must be correctly appended to the first recursive call. During the `add_graph_entry()` procedure, it looks for the source of the first recursive call and saves it to recursive_src. Next, if the current graph entry node is skipped, then the nr_calls is added to the add_calls_tgt. Signed-off-by: Daon Park <deeopark39@gmail.com>
If a node is marked as True in the skip variable, the dump file will not record that node. Signed-off-by: Daon Park <deeopark39@gmail.com>
During a search for the source of the recursive call, it must check for NULL pointers. This passes the unittest 51 graph_basic. Signed-off-by: Daon Park <deeopark39@gmail.com>
During a search for the destination node for the nr_calls, it must check for NULL pointers. This passes the unittest 52 graph_command. Signed-off-by: Daon Park <deeopark39@gmail.com>
During the determination of a node skip, it must check for NULL pointers in the name. This passes the unittest 105 tui_command. Signed-off-by: Daon Park <deeopark39@gmail.com>
namhyung
reviewed
Oct 31, 2024
Owner
namhyung
left a comment
There was a problem hiding this comment.
Hello, thanks for your contribution.
First, you don't need to create a new PR for code changes. Just keep the PR and force-push changes to your branch.
Second, Please remove commits to add NULL checks and squash them to the original changes.
Third, I think you modified logic in the general code which will affect other graph codes that might not want to merge recursive calls. If so, you may want to pass an option (or set it globally somewhere) to control the behavior.
| struct uftrace_graph_node *curr = tg->node; | ||
| struct uftrace_fstack *fstack; | ||
| static uint32_t next_id = 1; | ||
| static bool skip = false; |
Owner
There was a problem hiding this comment.
I'm not sure if it needs to be 'static'.
| if (name) { | ||
| if (curr && curr->parent) { | ||
| skip = !strcmp(name, curr->name) && !strcmp(name, curr->parent->name); | ||
| } |
Owner
There was a problem hiding this comment.
No need for curly brackets on a single line statement.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
These commits include skipping the recursive calls during the dump of graphviz, and correctly adding number of calls of the skipped entries to the initial recursive call.
Fixed: #1500