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

Dynamically Linked Functions Library in CPP #23634

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

soumiiow
Copy link

Description

RFC for the changes prestodb/rfcs#24
These changes will allow users to dynamically load functions in prestissimo using cpp

Motivation and Context

Having these changes will enable users to register custom functions dynamically without requiring a fork of Prestissimo.

Impact

Test Plan

currently the unit test and container tests are still being debugged. and are being actively worked on

Contributor checklist

  • Please make sure your submission complies with our development, formatting, commit message, and attribution guidelines.
  • PR description addresses the issue accurately and concisely. If the change is non-trivial, a GitHub Issue is referenced.
  • Documented new properties (with its default value), SQL syntax, functions, or other functionality.
  • If release notes are required, they follow the release notes guidelines.
  • Adequate tests were added if applicable.
  • CI passed.

Release Notes

Please follow release notes guidelines and fill in the release notes below.

== RELEASE NOTES ==

General Changes
* ... :pr:`12345`
* ... :pr:`12345`

Hive Connector Changes
* ... :pr:`12345`
* ... :pr:`12345`

If release note is NOT required, use:

== NO RELEASE NOTE ==

@soumiiow soumiiow self-assigned this Sep 12, 2024
Copy link

linux-foundation-easycla bot commented Sep 12, 2024

CLA Missing ID CLA Not Signed

@tdcmeehan tdcmeehan self-assigned this Sep 12, 2024
Copy link
Contributor

@steveburnett steveburnett left a comment

Choose a reason for hiding this comment

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

Thanks for the documentation! I suggested some changes to the README to simplify some of the wording and improve readability.

If my suggestions change a sentence's meaning in a way that makes it incorrect, let me know and we can find a better phrasing together.

@@ -0,0 +1,23 @@
# Prestissimo: Dynamically Loading Function Library

This library adds the ability to load User Defined Functions (UDFs) without having to fork and build Prestissimo through the use of shared libraries. The Prestissimo worker is to access said code. The dynamic functions are to be loaded upon running an instance of the presto server. In the presto server instance, it will search for any .so or .dylib files and load them using this library.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
This library adds the ability to load User Defined Functions (UDFs) without having to fork and build Prestissimo through the use of shared libraries. The Prestissimo worker is to access said code. The dynamic functions are to be loaded upon running an instance of the presto server. In the presto server instance, it will search for any .so or .dylib files and load them using this library.
This library adds the ability to load User Defined Functions (UDFs) without having to fork and build Prestissimo, through the use of shared libraries that a Prestissimo worker can access. The dynamic functions are loaded on launch of the Presto server. The Presto server searches for any .so or .dylib files and loads them using this library.

Suggested changes for readability.


## Getting started

The Process can be roughly broken down into the steps below:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
The Process can be roughly broken down into the steps below:


The Process can be roughly broken down into the steps below:
### 1. Create a cpp file for your dynamic library
For dynamically loaded function registration, the format followed is mirrored of that of built-in function registration with some noted differences. For instance, the below example function uses the extern "C" keyword to protect against name mangling. Additionally, a registry() function call is also necessary here.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
For dynamically loaded function registration, the format followed is mirrored of that of built-in function registration with some noted differences. For instance, the below example function uses the extern "C" keyword to protect against name mangling. Additionally, a registry() function call is also necessary here.
For dynamically loaded function registration, the format is the same as for built-in function registration with some differences. For instance, the below example function uses the extern "C" keyword to protect against name mangling. A registry() function call is also necessary.

Copy link
Author

Choose a reason for hiding this comment

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

@steveburnett I was thinking here, for clarity, I could copy paste the test function in MyDynamicTestFunction.cpp so it clearly demonstrates the format of the function. do you think that would be a useful addition or repetitive as the reader can find the test function for themselves too

Copy link
Contributor

@steveburnett steveburnett Sep 12, 2024

Choose a reason for hiding this comment

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

I think it might be repetitive, but copy-pasting the test function in MyDynamicTestFunction.cpp here could also be valuable. It would depend how you write it. I could see it useful if you want to emphasize certain details, and if you keep the copied portion to the minimum number of lines needed so it doesn't overwhelm your steps here in the README.

I'd suggest that you try it and decide for yourself if you think it works or not.

If the part you need to copypaste is large, maybe discuss the test function here and include a link to the file MyDynamicTestFunction.cpp for readers.

target_link_libraries(name_of_dynamic_fn PRIVATE xsimd fmt::fmt velox_expression)
```

### 3. In the prestissimo worker's config.properties file, set the plugin.dir property
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
### 3. In the prestissimo worker's config.properties file, set the plugin.dir property
### 3. In the Prestissimo worker's config.properties file, set the plugin.dir property

```
plugin.dir="User\Test\Path\plugin"
```
### 4. Upon start of the Presto Server, this directory will be scanned and all shared libraries will be attempted to be dynamically loaded when the worker or the sidecar process starts.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
### 4. Upon start of the Presto Server, this directory will be scanned and all shared libraries will be attempted to be dynamically loaded when the worker or the sidecar process starts.
### 4. When the worker or the sidecar process starts, it scans this directory and attempts to dynamically load all shared libraries.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants