-
Notifications
You must be signed in to change notification settings - Fork 26
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
Improved Resource ownership #39
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like a lot of changes to fix a deadlock on resource shutdown and brings up some concerns about how intertwined the design is.
Also, I dont see a new test checking that the deadlock has been resolved.
It is a lot less intertwined now. |
Co-authored-by: Michael Demoret <42954918+mdemoret-nv@users.noreply.github.com>
Co-authored-by: Michael Demoret <42954918+mdemoret-nv@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Updating from branch-22.06
and will merge once CI passes
@gpucibot merge |
Fixes #35
Fixes #36
The primary issue that was causing #36 is shared_ptr creep. Usually the deferred deletion / pseudo-garbage collection enabled by shared_ptrs is useful, but in this case, the resources that own the worker threads are held in objects that are managed by shared_ptrs. In some cases, the worker threads are the last owners of these shared ptrs and thus exhibit a deadlock where a thread ultimately tries to join itself.
This PR removes all shared_ptrs from object/resources that could be potentially captured by worker threads and replaces them with references.
The code is structured so that all resources and worker threads are owned by the
Executor
->resources::Manager
and that all threads must be joined beforeresources::Manager
is destroyed.This ensures that the resources outlive the pipeline execution provided that the Executor stays in scope. If it goes out of scope or is destroyed it should issue a kill to the pipeline, but still block until all threads are joined.
All executor resources should be created and managed by
resources::Manager
as a single point for life cycle management.