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

[Bug] fix _build_tree_relationship in ProfilerResult #1256

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 35 additions & 2 deletions visualdl/component/profiler/parser/event_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,24 @@ def _build_tree_relationship( # noqa: C901
if not hasenter:
firstposition = i
hasenter = True
stack_top_node.runtime_node.append(runtimenode)
inserted_node = stack_top_node
runtimenode_stack = [stack_top_node]
while runtimenode_stack:
inserted_node = runtimenode_stack.pop()
if inserted_node is not None:
runtimenode_stack.append(inserted_node)
runtimenode_stack.append(None)
for child in reversed(inserted_node.runtime_node):
if runtimenode.start_ns >= child.start_ns and \
runtimenode.end_ns <= child.end_ns:
runtimenode_stack.append(child)
else:
inserted_node = runtimenode_stack.pop()
if runtimenode.start_ns >= inserted_node.start_ns and \
runtimenode.end_ns <= inserted_node.end_ns:
inserted_node.runtime_node.append(runtimenode)
break

else:
# from this runtime node, not within stack_top_node, erase the
# nodes from runtime_event_nodes
Expand All @@ -506,7 +523,23 @@ def _build_tree_relationship( # noqa: C901
if not hasenter:
firstposition = i
hasenter = True
stack_top_node.runtime_node.append(runtimenode)
inserted_node = stack_top_node
runtimenode_stack = [stack_top_node]
while runtimenode_stack:
inserted_node = runtimenode_stack.pop()
if inserted_node is not None:
runtimenode_stack.append(inserted_node)
runtimenode_stack.append(None)
for child in reversed(inserted_node.runtime_node):
if runtimenode.start_ns >= child.start_ns and \
runtimenode.end_ns <= child.end_ns:
runtimenode_stack.append(child)
else:
inserted_node = runtimenode_stack.pop()
if runtimenode.start_ns >= inserted_node.start_ns and \
runtimenode.end_ns <= inserted_node.end_ns:
inserted_node.runtime_node.append(runtimenode)
break
else:
# from this runtime node, not within stack_top_node, erase the
# nodes from runtime_event_nodes
Expand Down