Skip to content

MDEV-36234: Dual stack libaio/liburing #3976

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

Draft
wants to merge 11 commits into
base: 10.6
Choose a base branch
from
Draft

MDEV-36234: Dual stack libaio/liburing #3976

wants to merge 11 commits into from

Conversation

dr-m
Copy link
Contributor

@dr-m dr-m commented Apr 15, 2025

  • The Jira issue number for this PR is: MDEV-36234

Description

FIXME: Introduce a parameter for explicitly specifying which one to use: innodb_linux_aio=libaio/liburing/auto

FIXME: In srv_start(), indicate which implementation was chosen

Release Notes

TBD

How can this PR be tested?

TBD

Basing the PR against the correct MariaDB version

  • This is a new feature or a refactoring, and the PR is based against the main branch.
  • This is a bug fix, and the PR is based against the earliest maintained branch in which the bug can be reproduced.

We may want to base this on 10.11 instead of 10.6, if there is no liburing capable GNU/Linux distribution that would by default ship 10.6.

PR quality check

  • I checked the CODING_STANDARDS.md file and my PR conforms to this where appropriate.
  • For any trivial modifications to the PR, I am ok with the reviewer making the changes themselves.

FIXME: Introduce a parameter for explicitly specifying which one to use:
innodb_linux_aio=libaio/liburing/auto

FIXME: In srv_start(), indicate which implementation was chosen
@dr-m dr-m requested a review from vaintroub April 15, 2025 09:17
@dr-m dr-m self-assigned this Apr 15, 2025
@CLAassistant
Copy link

CLAassistant commented Apr 15, 2025

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
2 out of 3 committers have signed the CLA.

✅ vaintroub
✅ grooverdan
❌ dr-m
You have signed the CLA already but the status is still pending? Let us recheck it.

Debian packaging is no longer aio exclusive or uring, so
for those older versions, its a remove_uring directive.

Add manditory liburing for consistent packaging, if
workers need to be updated that can be handled.

WITH_LIBAIO is now an independent option from WITH_URING.
@grooverdan grooverdan force-pushed the MDEV-36234 branch 2 times, most recently from b1e9ea3 to 5157b6e Compare April 16, 2025 05:51
Add abstraction to return implementation name from
threadpool.
Remove version check on the kernel as it now corresponds to
a working RHEL9 kernel and the problem was only there in
pre-release kernels that shouldn't have been used in production.

This reverts commit 3dc0d88.
...when using io_uring on a potentially affected kernel"

Remove version check on the kernel as it now corresponds to
a working RHEL9 kernel and the problem was only there in
pre-release kernels that shouldn't have been used in production.

This reverts commit 1193a79.
Noted in MDEV-36542 that it wasn't used and
the compile warning -Wunused-private-field is legitimate.

Review: Vladislav Vaintroub
As noted by Jens Axobe, errno isn't set, it is returned
by the io_uring_queue_init function.
This controls which linux implementation to use under the
assumption that innodb_native_aio is true.

"auto" select liburing first, if fails, tries libaio with
a filesystem test, and if fails, falls back to no-async.
"aio" starts is per auto, but skips liburing step.
The examination of the AIO method needs to occur after
the os_aio_init has been completed.
Copy link
Member

@vaintroub vaintroub left a comment

Choose a reason for hiding this comment

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

Fixed Windows compilation. Other than that, and minor commit on unnecessary attribute(unused), I do not have any objections

#ifdef HAVE_URING
aio *create_libaio(thread_pool *pool, int max_io)
#else
aio *create_linux_aio(thread_pool *pool, int max_io, aio_implementation implementation __attribute__((unused)))
Copy link
Member

Choose a reason for hiding this comment

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

Drop the implementation __attribute__((unused)) from this line. Just aio_implementation. It's cleaner

It is C++, if you do not have to name parameter, if you do not use them.

@vaintroub vaintroub requested a review from Copilot April 16, 2025 08:58
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 14 out of 21 changed files in this pull request and generated 2 comments.

Files not reviewed (7)
  • debian/autobake-deb.sh: Language not supported
  • debian/rules: Language not supported
  • mysql-test/mariadb-test-run.pl: Language not supported
  • mysql-test/suite/sys_vars/r/innodb_linux_aio_basic.result: Language not supported
  • mysql-test/suite/sys_vars/t/innodb_linux_aio_basic.test: Language not supported
  • mysql-test/suite/sys_vars/t/sysvars_innodb.test: Language not supported
  • tpool/CMakeLists.txt: Language not supported
Comments suppressed due to low confidence (3)

tpool/tpool_generic.cc:220

  • Please verify that the removal of m_group_enqueued is intentional; if it was tracking any necessary metrics, ensure these metrics are either no longer needed or are correctly handled elsewhere.
unsigned long long m_group_enqueued;

storage/innobase/handler/ha_innodb.cc:19516

  • There is a spelling mistake in the documentation: 'implementaiton' should be corrected to 'implementation'.
Specifies which InnoDB AIO implementaiton should used. Possible value are "auto" ...

tpool/aio_linux.cc:120

  • [nitpick] Double-check that using reinterpret_cast here is safe and that event.obj is always of type aiocb*. This cast assumes a specific memory layout; consider adding a static_assert or runtime check if feasible.
aiocb *iocb= reinterpret_cast<aiocb*>(event.obj);

@@ -300,12 +299,12 @@ class thread_pool_generic : public thread_pool
void wait_begin() override;
void wait_end() override;
void submit_task(task *task) override;
aio *create_native_aio(int max_io) override
aio *create_native_aio(int max_io, aio_implementation implementation) override
{
#ifdef _WIN32
return create_win_aio(this, max_io);
Copy link
Preview

Copilot AI Apr 16, 2025

Choose a reason for hiding this comment

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

Ensure that all callers of create_native_aio have been updated to pass the appropriate aio_implementation argument, to maintain consistency with the new function signature.

Suggested change
return create_win_aio(this, max_io);
return create_win_aio(this, max_io, implementation);

Copilot uses AI. Check for mistakes.

max_events,
tpool::OS_AIO);
if (!ret && !is_linux_native_aio_supported())
{
Copy link
Preview

Copilot AI Apr 16, 2025

Choose a reason for hiding this comment

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

[nitpick] Clarify the fallback behavior when native AIO is unsupported. An inline comment explaining why ret is set to 1 in this case would improve maintainability.

Suggested change
{
{
int // Fallback: Set ret to 1 to indicate that native AIO is unsupported,
// and we should proceed with non-native AIO methods.

Copilot uses AI. Check for mistakes.

srv_use_native_aio= false;
ret= srv_thread_pool->configure_aio(false, max_events);
}
switch (srv_linux_aio_method)
Copy link
Member

Choose a reason for hiding this comment

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

Suggestion : I think most of this if linux fallback logic (uring to libaio) could be handled inside tpool::configure_aio itself, you got the OS_DEFAULT for it, right? Will be less clutter here and you can put OS_DEFAULT to use

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

Successfully merging this pull request may close these issues.

4 participants