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

python plugins: enable direct I/O in core instead of calling python for read and write #1297

Merged
merged 32 commits into from Dec 7, 2022

Conversation

pstorz
Copy link
Member

@pstorz pstorz commented Oct 28, 2022

The filedaemon api calls the plugin for doing the actual file I/O (i.e. reading during backup and writing during restore).
This is by far the most frequently called function in the plugin api and thus can have big impact on the overall performance.

This PR enables python plugins to pass the filedescriptor that is intended to do the I/O in the open call of the file in
plugin_io_open(), IOP.filedes needs to be set to the filedescriptor for the file, and IOP.status needs to be set to bareosfd.iostat_do_in_core. Otherwise the IOP.status should be set to bareosfd.iostat_do_in_plugin
Example:

            # do io in core
            IOP.filedes = self.file.fileno()
            IOP.status =  bareosfd.iostat_do_in_core
 
            #  do io in plugin
            #IOP.status = bareosfd.iostat_do_in_plugin

In our test environment, the backup speed could be more than doubled so that the backup via python plugin was as fast as a backup directly via the filedaemon.

Please check

  • Short description and the purpose of this PR is present above this paragraph
  • Your name is present in the AUTHORS file (optional)

If you have any questions or problems, please give a comment in the PR.

Helpful documentation and best practices

Checklist for the reviewer of the PR (will be processed by the Bareos team)

General
  • PR name is meaningful
  • Purpose of the PR is understood
  • Commit descriptions are understandable and well formatted
  • Check backport line
  • Is the PR title usable as CHANGELOG entry?
  • Separate commit for CHANGELOG.md ("update CHANGELOG.md"). The PR number is correct.
Source code quality
  • Source code changes are understandable
  • Variable and function names are meaningful
  • Code comments are correct (logically and spelling)
  • Required documentation changes are present and part of the PR
  • bareos-check-sources --since-merge does not report any problems
Tests
  • Decision taken that a test is required (if not, then remove this paragraph)
  • The choice of the type of test (unit test or systemtest) is reasonable
  • Testname matches exactly what is being tested
  • On a fail, output of the test leads quickly to the origin of the fault

@pstorz pstorz force-pushed the dev/pstorz/master/plugin_io_in_core branch from 5f4651c to 99c4c04 Compare October 28, 2022 11:12
@pstorz pstorz requested a review from arogge October 28, 2022 15:25
@pstorz pstorz force-pushed the dev/pstorz/master/plugin_io_in_core branch from 3f3fe3a to 43b89d7 Compare November 3, 2022 16:51
Copy link
Member

@arogge arogge left a comment

Choose a reason for hiding this comment

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

I think we should try to get rid of do_io_in_core and handle that with magic values for filedes.

core/src/filed/fd_plugins.cc Outdated Show resolved Hide resolved
core/src/filed/fd_plugins.cc Outdated Show resolved Hide resolved
core/src/filed/fd_plugins.h Outdated Show resolved Hide resolved
core/src/filed/fd_plugins.cc Outdated Show resolved Hide resolved
core/src/filed/fd_plugins.cc Show resolved Hide resolved
core/src/filed/fd_plugins.cc Outdated Show resolved Hide resolved
core/src/filed/fd_plugins.cc Show resolved Hide resolved
core/src/filed/fd_plugins.cc Outdated Show resolved Hide resolved
core/src/filed/fd_plugins.h Show resolved Hide resolved
@pstorz pstorz force-pushed the dev/pstorz/master/plugin_io_in_core branch from d23856d to 6910cdc Compare November 11, 2022 19:29
core/src/filed/fd_plugins.h Outdated Show resolved Hide resolved
Copy link
Member

@arogge arogge left a comment

Choose a reason for hiding this comment

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

Looks a lot simpler already. Still some caveats, but steadily improving.

core/src/filed/fd_plugins.cc Show resolved Hide resolved
// - Set the io.filedes to the filedescriptor of the file that was
// opened in the plugin. In this case the core code will read from
// write to that filedescriptor during backup and restore.
// 2.: - Set io.status to IoStatus::success, and
Copy link
Member

Choose a reason for hiding this comment

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

was this truncated? At least it doesn't make sense to me.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, this was updated.

Copy link
Member

Choose a reason for hiding this comment

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

no, still truncated :(

core/src/plugins/filed/python/module/bareosfd.h Outdated Show resolved Hide resolved
core/src/plugins/filed/python/module/bareosfd.h Outdated Show resolved Hide resolved
docs/manuals/source/DeveloperGuide/PythonPluginAPI.rst Outdated Show resolved Hide resolved
docs/manuals/source/DeveloperGuide/PythonPluginAPI.rst Outdated Show resolved Hide resolved
@pstorz pstorz force-pushed the dev/pstorz/master/plugin_io_in_core branch 2 times, most recently from 82b0b0a to 847d7cb Compare November 29, 2022 17:48
@pstorz pstorz requested a review from arogge November 30, 2022 11:48
Copy link
Member

@arogge arogge left a comment

Choose a reason for hiding this comment

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

Some minor scoping and re-initialization issues left.
Also, we should probably change the struct io_pkt everywhere throughout the codebase.

core/src/filed/fd_plugins.cc Outdated Show resolved Hide resolved
core/src/filed/fd_plugins.cc Show resolved Hide resolved
core/src/filed/fd_plugins.cc Show resolved Hide resolved
// - Set the io.filedes to the filedescriptor of the file that was
// opened in the plugin. In this case the core code will read from
// write to that filedescriptor during backup and restore.
// 2.: - Set io.status to IoStatus::success, and
Copy link
Member

Choose a reason for hiding this comment

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

no, still truncated :(

core/src/filed/fd_plugins.h Outdated Show resolved Hide resolved
core/src/filed/fd_plugins.cc Outdated Show resolved Hide resolved
@pstorz pstorz force-pushed the dev/pstorz/master/plugin_io_in_core branch from 84c66e1 to aa4534d Compare December 1, 2022 11:50
@pstorz pstorz requested a review from arogge December 1, 2022 12:21
Copy link
Member

@arogge arogge left a comment

Choose a reason for hiding this comment

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

some really minor things left. Sorry.

core/src/plugins/filed/python/module/bareosfd.cc Outdated Show resolved Hide resolved
core/src/plugins/filed/python/module/bareosfd.h Outdated Show resolved Hide resolved
@pstorz pstorz requested a review from arogge December 5, 2022 08:20
Copy link
Member

@arogge arogge left a comment

Choose a reason for hiding this comment

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

bareos-check-source brought up some issues and the test configuration probably doesn't work as intended.

@pstorz pstorz force-pushed the dev/pstorz/master/plugin_io_in_core branch from 1e2fb47 to 9952746 Compare December 5, 2022 13:24
@arogge arogge force-pushed the dev/pstorz/master/plugin_io_in_core branch 3 times, most recently from 6cec9e2 to 74eb304 Compare December 5, 2022 18:22
@arogge arogge enabled auto-merge December 5, 2022 18:29
@arogge arogge force-pushed the dev/pstorz/master/plugin_io_in_core branch from 2800b28 to 3bb485a Compare December 6, 2022 14:56
pstorz and others added 25 commits December 7, 2022 13:18
Implement `plugin_io_open()` so that we can configure direct I/O and
pass the filedescriptor.
Sentinels for PyRestorePacket_members and PyIoPacket_members were
incomplete and are now corrected.
Change every wrong use of "#" to comment out a bconsole command to the
correct "@#" that will actually comment out the command and will not
produce the error message "#: is an invalid command."
As do_io_in_core was removed from IoPacket again, the test should not
check for it.
In bareosJobMsg() and bareosDebugMsg()
Change python-local-fileset-test to also use io_in_core.
The basic and io_in_core tests in py{2,3}plug-fd-local-fileset-basic
will run into UTF-8 conversion errors when running under the python3
plugin.
Until this problem is fixed, these tests are now marked as broken.
enum IoStatus: wrap into namespace
Replaces exec_program() with the newer execute_process().
The tests in pyplug-fd-local-fileset-basic are now enabled and disabled
as originally intended.
Change status messages to use unicode "check mark" and "ballot x" when
showing if a test was enabled/disabled.
Also prints the directory containing the test now.
Changes the implementation of BareosFdPluginLocalFilesBaseclass to
handle non-utf8 encodable file-names gracefully.
Instead of crashing we will now emit an M_ERROR that the file's name
cannot be represented and go on with the next file.
@arogge arogge force-pushed the dev/pstorz/master/plugin_io_in_core branch from da73322 to 9ffa0bf Compare December 7, 2022 12:38
due to issues with multibyte files in the baseclass when using python3,
we mark this test as broken for python3, as it will fail when python
thinks the filesystem is in ascii-mode.
@arogge arogge force-pushed the dev/pstorz/master/plugin_io_in_core branch from 9ffa0bf to b39cdeb Compare December 7, 2022 12:53
@arogge arogge merged commit 23d60b0 into master Dec 7, 2022
@pstorz pstorz deleted the dev/pstorz/master/plugin_io_in_core branch April 17, 2023 14:09
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.

None yet

2 participants