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

Use weak_ptr in node requirements list #771

Merged
merged 6 commits into from
Jul 22, 2022

Conversation

illuhad
Copy link
Collaborator

@illuhad illuhad commented Jul 14, 2022

Previously, dag_node has maintained shared_ptr objects to its requirements in the dependency graph. For deep dependency graphs, this can prevent nodes from being deleted even if the underlying operation has already completed since they might still be referenced.
So far, this has not been a huge issue. However, with the introduction of event pools in #757, this becomes important: If the DAG node cannot be deleted, its event stays alive and cannot be returned to the pool. In the worst case, this can prevent us from benefiting from the event pool at all, having to create individual events for each operation again.

To fix this, this PR changes the requirements list to weak_ptr so that DAG nodes can be deleted as soon as their operation has finished.

TODO: Seems to work on GPU, but still crashes on CPU. Presumably because CPU backend has its own worker thread to execute kernels, and this additional asynchronous behavior probably changes the lifetime guarantees of DAG nodes.

@illuhad illuhad marked this pull request as ready for review July 22, 2022 16:34
@illuhad
Copy link
Collaborator Author

illuhad commented Jul 22, 2022

At last, this should be stable now :)

@illuhad illuhad merged commit bb1db13 into develop Jul 22, 2022
@illuhad illuhad deleted the feature/weak-ptr-node-requirements-list branch July 22, 2022 19:54
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.

None yet

1 participant