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

[ESI Runtime] Load backends as plugins #7260

Merged
merged 3 commits into from
Jul 3, 2024
Merged

Conversation

teqdruid
Copy link
Contributor

@teqdruid teqdruid commented Jul 2, 2024

If a backend isn't found in the registry, try to load it dynamically from some standard places. Note that if one doesn't want to keep the plugin shared lib in one of those places, one can LD_PRELOAD it.

Linux support only. Windows coming.

@teqdruid teqdruid added the ESI label Jul 2, 2024
@teqdruid teqdruid requested a review from mortbopet July 2, 2024 14:10
If a backend isn't found in the registry, try to load it dynamically
from some standard places. Note that if one doesn't want to keep the
plugin shared lib in one of those places, one can LD_PRELOAD it.

Linux support only. Windows to come.
@teqdruid teqdruid force-pushed the teqdruid/esirt/plugin-linux branch from c556067 to 7cb376b Compare July 2, 2024 14:13
@teqdruid teqdruid marked this pull request as ready for review July 2, 2024 14:13
lib/Dialect/ESI/runtime/CMakeLists.txt Outdated Show resolved Hide resolved
lib/Dialect/ESI/runtime/CMakeLists.txt Outdated Show resolved Hide resolved
#endif
}

static void loadDynamic(string backend) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. const std::string&
    my eyes always go oogley reading files with using namespace std;.

  2. Suggesting function rename to loadBackend + add a small comment.

  3. I think there should be two functions; one as is (which tries to infer the backend path), and one which takes an absolute path to a backend. I'd imagine there should also be some option for users of ESI to manually provide the path to a backend, instead of relying on relative directory and backend name heuristics.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. const std::string&
    my eyes always go oogley reading files with using namespace std;.

Yeah, using namespace std is a bad habit I got into when first learning C++ in high school.

Can't use const since the string gets modified.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3. I think there should be two functions; one as is (which tries to infer the backend path), and one which takes an absolute path to a backend. I'd imagine there should also be some option for users of ESI to manually provide the path to a backend, instead of relying on relative directory and backend name heuristics.

I think it's fair to use LD_PRELOAD for other non-standard path plugins.

Comment on lines 141 to 145
loadDynamic(backend);
f = internal::backendRegistry.find(backend);
if (f == internal::backendRegistry.end())
throw runtime_error("Backend not found");
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bit in extension of the above; i fear this is some hard-to-debug code, in case there is a naming mismatch somewhere in the whole backend code registration/library naming.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll add a note to add debug logging when we get a logging framework.

@teqdruid teqdruid merged commit e0dbc64 into main Jul 3, 2024
2 checks passed
@teqdruid teqdruid deleted the teqdruid/esirt/plugin-linux branch July 3, 2024 09:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants