-
Notifications
You must be signed in to change notification settings - Fork 54
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
Plugin multi-instance support #1600
base: main
Are you sure you want to change the base?
Conversation
* Converted plugins to configuration objects * Added multi-instance support to samplers: * procnetdev2 * meminfo * avro_kafka store * csv store * sos store * Converted all samplers to support new plugin infrastructure * Changed configuration object reference counting to use ref_t
In before all the multi-instance code, the "name" field in the configuration was the name of the plugin. But since each plugin had only a single instance, we could also consider "name" the instance name. Instead of adding and "instance" attribute, we add a "plugin" attribute. "name" becomes the instance name. If "plugin" is not specified, "name" is also the plugin name.
…ots of other stuff
… (for backwards compatibility)
26b11e6
to
80c98da
Compare
600d005
to
6d0ca86
Compare
6d0ca86
to
3d2e040
Compare
c55f4c4
to
1bfa0eb
Compare
As of commit 1bfa0eb, things are basically working for multi instance samplers at least. I converted the "filesingle" plugin to work with the new multi-instance scheme, and load/config/sample/term all seem to be working (even interleaving command from different instances). Lots of work still to do, but at least a working proof-of-concept. |
@morrone re term(). I understand that destroying an instance is not, in the long run, what term should be. on the other hand I do see a role for a plugin_destroy (the artist formally known as term) in a system where plugins are loaded, unloaded, and loaded again with a replacement class definition without shutting down a daemon. In portability, I see plugin_destroy being distinct from instance destroy or a linker specific dtor. Basically, if we have a load command, should we not have an unload command? |
There is still an "unload" command in this code. It results in calling the plugin's term() first (for legacy plugins), and then calls instance_destroy(). I've been debating the value of adding "put_plugin()" to mirror "get_plugin()". Something to note: In Tom's code, and carried over into mine, each "load" command results in get_plugin() being called again. Each instance is started by a "load". This is redundant in my code (but not Tom's) because get_plugin() only returns the API of the plugin in my code. No state is to be created in get_plugin() (except in legacy code that will eventually be removed). So I could add a "put_plugin()" for symmetry, but it would just be called in the unload after term() (deprecated) and instance_destroy(). It wouldn't likely do anything. In other words, "get_plugin()" is currently called one every load command, and going through the entire plugin search and dlopen() process. It happens for every instance. So you shouldn't need to call unload() to start using a new version of a plugin that is already in use. And actually, I have in mind a plan to get rid of get_plugin() altogether. I don't know if folks will accept it in time for 4.5.1 though. But my plan would be to get rid of get_plugin() and just have plugins implement and export published ldmsd API function names, such as:
And so on. If that happens, then there is no nead for get_plugin() or put_plugin(). At load command time, the dlopen() happens, and available symbols are dlsym mapped. Then instance_create() is called. At unload command time, instance_destroy() is called, and dlclose() happens. |
This builds on @tom95858's PR #1575. Still a work in progress, but it is worth people seeing where things stand.
The general approach is to: