Replies: 4 comments 10 replies
-
Let's limit the scope of this discussion to the present V4 plugins api, not an improved V5 where plugins with multiple instance no longer need to use so many globals. The underlying considerations apply to both of course. For store plugins specifically an a normal ldmsd exit, the store's ".close" function is called by ldmsd on all the running store handles. In an abnormal termination (which happens often enough in production scenarios), the ((destructor)) function gets called. In either scenario, we need to keep the code maintainable/debuggable (particularly for memory leaks) by doing the following:
If we don't do an orderly cleanup, we end up with daemons that hang or core dump, which is very very disconcerting to production system administrators. The v4 api includes ((constructor)), config, open, store, flush, close, term, ((destructor)). It is desirable where possible, as indicated elsewhere by @morrone, to avoid putting code in ((const/dest-ructor)) at all. |
Beta Was this translation helpful? Give feedback.
-
On the v4 'sampler' plugin api (which arguably the stream csv store should be using), the rdc_sampler/rdc_plugin.c:term() similarly cleans up global gpu resources in a thread safe manner. |
Beta Was this translation helpful? Give feedback.
-
Unfortunately there probably needs to be further software development needed to allow us to give a clean and consistent answer to that question. For instance, I have a long standing issue #51 open on the fact that ldms fails to call the term() function for sampler plugins before it exits. If that has been addressed, I would love to know about it. Generally speaking, a plugin should stop everything it was doing in term(), close all file descriptors, free all memory that it allocated. Essentially it must ensure that it erases all evidence of itself from memory when the term() API is called. term() is where all normal plugin cleanup should happen. When you mention "fini", I assume you are talking about the gcc attribute ((destructor)). I would argue that this should almost never be used. Most places I have seen it used so far is because the entity calling the plugin (ldmsd) is being exceedingly sloppy and failing to call term() on the plugins before exit, so the "fini" destructor is used as a cludge. I don't think we should advertise the use of the destructor (fini) in an LDMSCON setting. Rather, we should repair ldmsd's interaction with plugins. |
Beta Was this translation helpful? Give feedback.
-
The constructor/destructor approach creates lots of problems. Most of them
have to do with thread creation and fork, but in general, to be useful the
approach is only useful if you're managing state globally, i.e. the entry
points don't have handles. So I agree Chris.
…On Wed, Sep 1, 2021 at 5:57 PM Christopher J. Morrone < ***@***.***> wrote:
I would suggest that general pre-config() initialization should happen in
"get_plugin()". get_plugin is the first, required entry into any plugin, so
it is probably the best place to pre-allocate things "outside of config". I
think that is a much better approach then using constructors and
destructors. The matching place to deallocate those things (as well as
everything else) would be term().
Ideally our API would have more symmetrically named calls. I'll continue
to argue for that in the new API. :)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#785 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABVTPXEIDV6G5FFJDXW7VGLT72VUDANCNFSM5DE2A3LQ>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
--
Thomas Tucker, President, Open Grid Computing, Inc.
|
Beta Was this translation helpful? Give feedback.
-
@morrone @valleydlr @tom95858 @baallan
We need some clarity on the end state for plugins --- what goes into the term, fini etc.
There is some inconsistency in the current plugins and it would be good to clear this up both for LDMSCON and for the stream_store_csv plugin.
Can we settle this quickly in this thread?
An existing plugin to model off of would be great!
Beta Was this translation helpful? Give feedback.
All reactions