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

Makefile support to statically link external plugin code #7918

Closed
wants to merge 8 commits into from

Conversation

ajkr
Copy link
Contributor

@ajkr ajkr commented Feb 2, 2021

Added support for detecting plugins linked in the "plugin/" directory and building them from our Makefile in a standardized way. See "plugin/README.md" for details. An example of a plugin that can be built in this way can be found in https://github.com/ajkr/dedupfs.

There will be more to do in terms of making this process more convenient and adding support for CMake.

Test Plan: my own plugin (https://github.com/ajkr/dedupfs) and also heard this patch worked with ZenFS.

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

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

@facebook-github-bot
Copy link
Contributor

@ajkr has updated the pull request. You must reimport the pull request before landing.

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

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

@ajkr ajkr requested a review from siying February 2, 2021 01:55
Copy link
Contributor

@mrambacher mrambacher left a comment

Choose a reason for hiding this comment

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

I am a little confused as to how this is supposed to work. I am not certain I understand how adding the plugin to the master library solves anything (how do any of the function in the plugin get called in something like db_bench), and I do not understand how the directory tree gets established.

Makefile Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
Makefile Show resolved Hide resolved
Copy link
Contributor Author

@ajkr ajkr left a comment

Choose a reason for hiding this comment

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

I am not certain I understand how adding the plugin to the master library solves anything (how do any of the function in the plugin get called in something like db_bench)

This is exactly demonstrated in the example: https://github.com/ajkr/dedupfs

I do not understand how the directory tree gets established.

By the user. See the example

Makefile Show resolved Hide resolved
Makefile Show resolved Hide resolved
@facebook-github-bot
Copy link
Contributor

@ajkr has updated the pull request. You must reimport the pull request before landing.

2 similar comments
@facebook-github-bot
Copy link
Contributor

@ajkr has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot
Copy link
Contributor

@ajkr has updated the pull request. You must reimport the pull request before landing.

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

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

@ajkr ajkr requested a review from ramvadiv February 2, 2021 23:38
Copy link
Contributor

@pdillinger pdillinger left a comment

Choose a reason for hiding this comment

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

This looks to be a great first implementation of the agreed-upon design 👍👍

Makefile Outdated
# To achieve this on Mac OS X, the static library must be preceded by `-force_load`
# linker flag. Elsewhere, the library must be surrounded by `--whole-archive` and
# `--no-whole-archive`.
$(warning "platform $(PLATFORM)")
Copy link
Contributor

Choose a reason for hiding this comment

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

Debug print?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, will remove it.

Copy link
Contributor Author

@ajkr ajkr left a comment

Choose a reason for hiding this comment

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

Thanks very much for the review!

Makefile Outdated
# To achieve this on Mac OS X, the static library must be preceded by `-force_load`
# linker flag. Elsewhere, the library must be surrounded by `--whole-archive` and
# `--no-whole-archive`.
$(warning "platform $(PLATFORM)")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, will remove it.

@mrambacher
Copy link
Contributor

I agree that this is a good first pass and is something that could potentially be marked "experimental". There are quite a few issues I see before we could mark this is "ready":

  • The size of the executables grows substantially in this mode;
  • There is no way to tell what plugins are installed/available in the library;
  • Without CMAKE support, this will not work on Windows and potentially other platforms
  • There needs to be a means to build and run the tests against the plugins
  • Support for shared libraries (and potentially external libraries) is also needed

This work dovetails with some of the work I have been doing in #6591. I will write something up to bring those two efforts together and try to address some of these issues.

@facebook-github-bot
Copy link
Contributor

@ajkr has updated the pull request. You must reimport the pull request before landing.

@mrambacher
Copy link
Contributor

Should there also be a way to add/build custom tests? For example, if one viewed the "BackupableDB" suite as a plugin, how would one build those tests using this model?

@ajkr
Copy link
Contributor Author

ajkr commented Feb 9, 2021

I agree that this is a good first pass and is something that could potentially be marked "experimental". There are quite a few issues I see before we could mark this is "ready":

The release note claims a "mechanism for building external plugin code into the RocksDB libraries/binaries". In my view, the public interface consists of the *.mk files in the plugin directory, which can specify source files, header files, and linker flags. I am pretty convinced we should provide the mechanism, and haven't heard concerns about the interface as described, so do not see a reason to mark the support introduced here as experimental.

  • The size of the executables grows substantially in this mode;

This is addressed by no longer adding -Wl,--whole-archive.

  • There is no way to tell what plugins are installed/available in the library;
  • Without CMAKE support, this will not work on Windows and potentially other platforms
  • There needs to be a means to build and run the tests against the plugins
  • Support for shared libraries (and potentially external libraries) is also needed

I agree these would be nice to have. However, the release note only claims a "mechanism for building external plugin code into the RocksDB libraries/binaries".

This work dovetails with some of the work I have been doing in #6591. I will write something up to bring those two efforts together and try to address some of these issues.

I think it is a great long-term direction. As it relates to this PR, I expect the "building-in" mechanism introduced here will still be needed.

edit: Actually, the release note should be constrained further to say the mechanism is only available to Makefile users. I will fix that before landing.

@facebook-github-bot
Copy link
Contributor

@ajkr has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot
Copy link
Contributor

@ajkr has updated the pull request. You must reimport the pull request before landing.

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

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

@facebook-github-bot
Copy link
Contributor

@ajkr merged this pull request in c16d5a4.

codingrhythm pushed a commit to SafetyCulture/rocksdb that referenced this pull request Mar 5, 2021
Summary:
Added support for detecting plugins linked in the "plugin/" directory and building them from our Makefile in a standardized way. See "plugin/README.md" for details. An example of a plugin that can be built in this way can be found in https://github.com/ajkr/dedupfs.

There will be more to do in terms of making this process more convenient and adding support for CMake.

Pull Request resolved: facebook#7918

Test Plan: my own plugin (https://github.com/ajkr/dedupfs) and also heard this patch worked with ZenFS.

Reviewed By: pdillinger

Differential Revision: D26189969

Pulled By: ajkr

fbshipit-source-id: 6624d4357d0ffbaedb42f0d12a3fcb737c78f758
george-lorch pushed a commit to percona/rocksdb that referenced this pull request May 10, 2021
Summary:
Added support for detecting plugins linked in the "plugin/" directory and building them from our Makefile in a standardized way. See "plugin/README.md" for details. An example of a plugin that can be built in this way can be found in https://github.com/ajkr/dedupfs.

There will be more to do in terms of making this process more convenient and adding support for CMake.

Pull Request resolved: facebook#7918

Test Plan: my own plugin (https://github.com/ajkr/dedupfs) and also heard this patch worked with ZenFS.

Reviewed By: pdillinger

Differential Revision: D26189969

Pulled By: ajkr

fbshipit-source-id: 6624d4357d0ffbaedb42f0d12a3fcb737c78f758
(cherry picked from commit c16d5a4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants