-
Notifications
You must be signed in to change notification settings - Fork 8
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
Better object lifetime management in margo #285
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #285 +/- ##
==========================================
+ Coverage 57.51% 57.64% +0.12%
==========================================
Files 70 70
Lines 9910 10150 +240
Branches 1282 1337 +55
==========================================
+ Hits 5700 5851 +151
- Misses 3422 3464 +42
- Partials 788 835 +47 ☔ View full report in Codecov by Sentry. |
I haven't reviewed the code yet, but just for discussion since (to my knowledge) we haven't had a dependency on c11 features before: are there any portability concerns? |
|
I realize I will need to fix something: I thought delaying freeing the hg class would be enough but actually I want to also delay freeing the hg context until the end, in case the user still has RPC ids to deregister. I'll also change "refincr" and "refdecr" to "ref_incr" and "release" for consistency with the ref count methods of the Margo instance. |
Ok I think I'm done with this PR, here are the highlights: With respect to margo instance ref-counting
The effect of this is that we now have a proper refcount that we can use in Thallium and PyMargo. The Another effect is that we can now do something like this:
With respect to re-counting of pools and xstreams managed by margo
This API will allow Bedrock to delegate the refcounting to Margo. Currently, Bedrock maintains a copy of the list of pools and xstreams just for the purpose of refcounting and preventing the removal of pools and xstreams that are used by providers. We can now leave that refcounting to the providers themself. TestingTests have been updated. |
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.
I started to say that it was odd that the counterpart to ref_incr
was release
(rather than ref_decr
), but then I realized that we had already started that convention with the instance functions, so we should stick with it.
It's too bad that it takes so many API calls but I don't see any way to avoid it. The code looks good to me.
This PR does the following:
This PR should make it easier to track who is using the margo instance in Thallium, allowing engine (and any other object that needs the margo instance) to increment and decrement its refcount, preventing it from being freed too early.