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

Change default node depth to infinity #16

Merged
merged 2 commits into from
Aug 1, 2023

Conversation

AustinT
Copy link
Collaborator

@AustinT AustinT commented Jul 31, 2023

Background: Previously a default value of -1 was assigned to this value, mostly just because it was obviously not a valid depth so it would be clear to users that this is just the default value. However, in some recent experiments with graph algorithms I observed that this could occasionally cause a lot of unnecessary updates when adding a new node to a graph caused a cycle. The depth update uses the minimum depth of any parent, so sometimes the value of -1 was propagated around the graph for a while (giving its children a depth of 0, their children a depth of 1, etc) until this was eventually corrected and all the nodes were updated a second time. Even though each update was short, the cumulative effect was quite large for large graphs: in one experiment with 10k calls to the reaction model, 40min/60min was spent doing these depth updates.

Rationale: by changing the default to infinity these redundant updates do not occur because the depth update uses the minimum depth of any parent, so no node in the graph with finite depth will have its depth updated if a node is added whose depth value is set to infinite.

Alternative considered: instead of changing the default I could have done very careful updates to ensure that this propagation of -1 never happened (e.g. update the node depths in a correct order). However, changing the default is easier, and infinity is probably a more sensible default value for depth anyway since it would correspond to no valid path to the root node. This value would also be stable if depth updates were run on graphs without a root node.

@AustinT AustinT requested a review from kmaziarz July 31, 2023 22:08
Copy link
Contributor

@kmaziarz kmaziarz left a comment

Choose a reason for hiding this comment

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

LGTM.

@AustinT AustinT merged commit d49a63b into microsoft:main Aug 1, 2023
3 checks passed
@AustinT AustinT deleted the check-default-node-depth branch August 1, 2023 17:30
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.

2 participants