Skip to content

feat: Add support for registering components dynamically#11439

Closed
soumiiow wants to merge 1 commit intofacebookincubator:mainfrom
soumiiow:velox-dylib
Closed

feat: Add support for registering components dynamically#11439
soumiiow wants to merge 1 commit intofacebookincubator:mainfrom
soumiiow:velox-dylib

Conversation

@soumiiow
Copy link
Copy Markdown
Contributor

@soumiiow soumiiow commented Nov 5, 2024

Allow users to dynamically register Velox components. Clients such as Presto can use this feature to dynamically load User Defined Functions, connectors, and types.

Based off: https://github.com/facebookincubator/velox/pull/1005/files

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Nov 5, 2024
@netlify
Copy link
Copy Markdown

netlify bot commented Nov 5, 2024

Deploy Preview for meta-velox canceled.

Name Link
🔨 Latest commit 542dd28
🔍 Latest deploy log https://app.netlify.com/sites/meta-velox/deploys/67ae9129d5bcfe000887fb9c

@Yuhta Yuhta requested a review from pedroerp November 5, 2024 15:40
@pedroerp
Copy link
Copy Markdown
Contributor

pedroerp commented Nov 5, 2024

@soumiiow thanks for looking into this. Out of curiosity, why doesn't this work in MacOS?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

we use snake case for directory names "dynamic_registry"

Copy link
Copy Markdown
Contributor

@pedroerp pedroerp left a comment

Choose a reason for hiding this comment

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

Very cool! I few small comments but overall looks good.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: new line before namespace definition.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

for consistency, could you use LOG(INFO) and print the file name / path of the library loaded?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

we can probably omit the "Functions" from the name, and this can be used to really load anything, as long as you provide the registration functions. Let's name it loadDynamicLibrary()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: the titles are too long; maybe just add the docs as a refular numbered list?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I pushed it out without the title formatting but does this look a bit cluttered now?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

can you use VELOX_ASSERT_THROW() instead to validate the right exception is being thrown?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

please vendor the macro. Maybe something like VELOX_TEST_DYNAMIC_LIBRARY_PATH

Comment on lines 22 to 23
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

please use the GTest:: targets

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please use target_compile_definitions( on the relevant target instead.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
velox_add_library(velox_dynamic_function_loader DynamicLibraryLoader.cpp)
velox_add_library(velox_dynamic_function_loader DynamicLibraryLoader.cpp)
velox_link_libraries(velox_dynamic_function_loader PRIVATE velox_exception)

Copy link
Copy Markdown
Collaborator

@aditi-pandit aditi-pandit left a comment

Choose a reason for hiding this comment

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

Thanks @soumiiow. Had bunch of minor comments, except for a bigger one around testing.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nit : rename registryFunction

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

hey!! so i got some previous feedback to stay away from the "registryFunction" in the naming so as to not make it seem like this library is to be used exclusively for functions, and to move away from our initial design which was made with only the function loading in mind. Perhaps, would there be a better name for this variable than the work "item"? I can only rlly think of registryItem or registryPtr but would love to hear your suggestions too

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@soumiiow : To me this is almost like the "main" function in a executable program. How about "loadLibrary" or "loadUserLibrary" or "enterUserLibrary" ? There could be code beyond registration here as well.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Add a comment "Invoke the registry function"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is not relevant in Velox. And also since its not used anywhere in the current code, its hard to put this in picture.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

It might be good to not talk about Prestissimo in this README.

This is a generic utility for dynamically loading a "registry" function from a library. Its sufficient to just say that this is for "Extensibility" features that add custom user code which could include new Velox types, functions, operators and connectors.

@soumiiow soumiiow force-pushed the velox-dylib branch 2 times, most recently from 45cf7af to 4e82b71 Compare December 4, 2024 07:04
@soumiiow soumiiow force-pushed the velox-dylib branch 2 times, most recently from b6660ad to eb20996 Compare January 7, 2025 16:55
Copy link
Copy Markdown
Collaborator

@aditi-pandit aditi-pandit left a comment

Choose a reason for hiding this comment

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

@soumiiow : Thanks for updating your tests. Have a bunch of questions.

@mohsaka
Copy link
Copy Markdown
Collaborator

mohsaka commented Jan 23, 2025

@soumiiow Addressed all of the unaddressed comments and made all of the changes for compilation on mac in this PR
#12111

Specifically this commit,
ac18115

@soumiiow soumiiow changed the title Dynamically Linked Library in CPP feat: Dynamically Linked Library in CPP Jan 27, 2025
@mohsaka mohsaka force-pushed the velox-dylib branch 4 times, most recently from e06974a to 3bbd8db Compare February 12, 2025 00:13
Copy link
Copy Markdown
Contributor

@pedroerp pedroerp left a comment

Choose a reason for hiding this comment

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

That's awesome. Thanks for adding support for this.

Made a few small comments, but overall it looks good to me. Feel free to tag "ready-to-merge" when they are addressed and I'll get it merged.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: remove this extra line

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LOG(INFO) << "Loaded library " << fileName << ". Searching registry symbol " << kSymbolName;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

do we also need to check if loadUserLibrary is nullptr?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Added, as well as a short comment explaining how it can be nullptr but we can't actually use it when its nullptr.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we also clarify that this only works if the builds are guaranteed to be based on the same Velox version and hence maintain ABI compatibility? This might not be immediate clear to users.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Added. Thanks!

@mohsaka mohsaka force-pushed the velox-dylib branch 7 times, most recently from 2dbe57e to 2ccbceb Compare February 12, 2025 16:54
@majetideepak majetideepak added the ready-to-merge PR that have been reviewed and are ready for merging. PRs with this tag notify the Velox Meta oncall label Feb 12, 2025
@majetideepak
Copy link
Copy Markdown
Collaborator

CI is green. @pedroerp can you please help import and merge? Thank you.

@majetideepak majetideepak changed the title feat: Dynamically Linked Library in CPP feat: Add support for loading shared libraries Feb 12, 2025
@majetideepak majetideepak changed the title feat: Add support for loading shared libraries feat: Add support for registering components dynamically Feb 12, 2025
…uccessful mac & linux compilation

Co-authored-by:  mohsaka <michael.ohsaka@ibm.com>
@facebook-github-bot
Copy link
Copy Markdown
Contributor

@pedroerp has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@czentgr
Copy link
Copy Markdown
Collaborator

czentgr commented Feb 14, 2025

@pedroerp the facebook builds&tools failed with a warning and the linter also reported a testing failure. Is this something that needs to be addressed in this PR? Thanks!

@mohsaka
Copy link
Copy Markdown
Collaborator

mohsaka commented Feb 14, 2025

@pedroerp the facebook builds&tools failed with a warning and the linter also reported a testing failure. Is this something that needs to be addressed in this PR? Thanks!

@czentgr It's been fixed on the Meta side already. The README needed a newline at the end of the file. If we need the change here, I can make it. But I believe they merge over there and close the PR here, merging back to main here.

I don't want to trigger a full pipeline rerun due to this.

@facebook-github-bot
Copy link
Copy Markdown
Contributor

@pedroerp merged this pull request in be9de86.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged ready-to-merge PR that have been reviewed and are ready for merging. PRs with this tag notify the Velox Meta oncall

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants