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

Make IO_SIZE compile-time configurable, convert comment to compile-time check, fix grammar #3726

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ericherman
Copy link
Contributor

@ericherman ericherman commented Dec 31, 2024

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

There is no JIRA for this simple refactoring.

Description

Making mariadb's IO_SIZE compile-time configurable enables more straight-forward investigation of the performance implications of having an IO_SIZE which is different than the memory page size.

By converting the text describing the constraints of the constant to a compile-time check, this enables us to make IO_SIZE configurable.

It should be noted that this #define is duplicated in the submodule libmariadb in the include/ma_global.h file.

Release Notes

Release notes might include the ability to define IO_SIZE to be a value other than 4096.

How can this PR be tested?

First, ensure that libmariadb is patched to #ifndef guard the #define IO_SIZE ( see: mariadb-corporation/mariadb-connector-c#265 ).

Next, add different values via cmake like -DIO_SIZE=8192 to see a larger value, or like -DIO_SIZE=4000 to see it fail with a compile-time error.

As this is a compile-time option this does not lend itself to automated testing.

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.

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.

@ericherman
Copy link
Contributor Author

This #define is duplicated in the submodule libmariadb in the include/ma_global.h file.

How are changes in mariadb-server's includes propagated to libmariadb's includes?

Is there an existing process?

Should I open a parallel PR for that?

@vuvova
Copy link
Member

vuvova commented Dec 31, 2024

libmariadb needs a special PR there's no automatic propagation

@ericherman ericherman force-pushed the eherman-io-size-20241231 branch from e0a9a93 to 16967b9 Compare December 31, 2024 14:33
ericherman added a commit to ericherman/mariadb-connector-c that referenced this pull request Dec 31, 2024
If the server is to make IO_SIZE configurable, we need to avoid either
redefining it, or defining it to be different.

See: MariaDB/server#3726

Signed-off-by: Eric Herman <[email protected]>
@ericherman
Copy link
Contributor Author

libmariadb needs a special PR there's no automatic propagation

I've created a draft PR: mariadb-corporation/mariadb-connector-c#265

I think I will create an MDEV for this work, as it crosses repository boundaries.

@ericherman ericherman marked this pull request as draft December 31, 2024 17:15
@ericherman ericherman changed the title Convert comment to compile-time check, fix grammar Make IO_SIZE configurable, convert comment to compile-time check, fix grammar Dec 31, 2024
#define IO_SIZE 4096U
#endif
#if ((IO_SIZE <= 0) || ((IO_SIZE % 512) != 0) || ((IO_SIZE & (IO_SIZE-1)) != 0))
Copy link
Contributor

Choose a reason for hiding this comment

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

This can be shortened to

#if IO_SIZE < 512 || (IO_SIZE & (IO_SIZE - 1))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. And with the text in the #error, I agree that it remains clear-enough. I shall adjust it.

@cvicentiu cvicentiu added the External Contribution All PRs from entities outside of MariaDB Foundation, Corporation, Codership agreements. label Jan 3, 2025
@ericherman ericherman changed the title Make IO_SIZE configurable, convert comment to compile-time check, fix grammar Make IO_SIZE compile-time configurable, convert comment to compile-time check, fix grammar Jan 3, 2025
@ericherman ericherman force-pushed the eherman-io-size-20241231 branch 2 times, most recently from 494fc45 to 780b924 Compare January 3, 2025 12:02
ericherman added a commit to ericherman/mariadb-connector-c that referenced this pull request Jan 3, 2025
If the server is to make IO_SIZE configurable, we need to avoid either
redefining it, or defining it to be different.

See: MariaDB/server#3726

Signed-off-by: Eric Herman <[email protected]>
By converting the text describing the constraints of the constant
to a compile-time check, this enables us to make IO_SIZE configurable.

It should be noted that this #define is duplicated in the submodule
libmariadb in the include/ma_global.h file.

Signed-off-by: Eric Herman <[email protected]>
Making mariadb's IO_SIZE compile-time configurable enables more
straight-forward investigation of the performance implications of having
an IO_SIZE which is different than the memory page size.

The default IO_SIZE of 4096 as defined in include/my_global.h and also
in libmariadb's include/ma_global.h matches to the memory page size of
most systems. Larger page sizes are widely supported, called "huge
pages" in Linux, "superpages" in FreeBSD, and "large pages" in MS
Windows.

On POSIX systems, obtaining the page size can be done via:

	page_size= sysconf(_SC_PAGESIZE);

On Windows:

	SYSTEM_INFO si;
	GetSystemInfo(&si);
	page_size= si.dwPageSize;

In https://jira.mariadb.org/browse/MDEV-35740 Marko highlights that
there are vastly different uses of IO_SIZE. This "one size fits all"
nature of IO_SIZE is not ideal, future work could split this into
separate constants based upon usage.

Note that libmariadb's include/ma_global.h should also be adjusted to
avoid a double #define of IO_SIZE and to ensure they are defined to be
the same.
See: mariadb-corporation/mariadb-connector-c#265

Signed-off-by: Eric Herman <[email protected]>
@ericherman ericherman force-pushed the eherman-io-size-20241231 branch from 780b924 to 9879b3d Compare January 3, 2025 12:57
ericherman added a commit to ericherman/mariadb-connector-c that referenced this pull request Jan 5, 2025
The server's definition of IO_SIZE is re-used here in the client for
network buffer alignment, however IO_SIZE is used in the server for
many different things and the client's buffer alignment is not related
to many of those uses.

If the server is to make IO_SIZE configurable, we need to avoid either
redefining it, or defining it to be different. By creating a specific
define for this, we avoid redfine and clarify the code.

See: MariaDB/server#3726

Signed-off-by: Eric Herman <[email protected]>
ericherman added a commit to ericherman/mariadb-connector-c that referenced this pull request Jan 5, 2025
The server's definition of IO_SIZE is re-used here in the client for
network buffer alignment, however IO_SIZE is used in the server for
many different things and the client's buffer alignment is not related
to many of those uses.

If the server is to make IO_SIZE configurable, we need to avoid either
redefining it, or defining it to be different. By creating a specific
define for this, we avoid redfine and clarify the code.

See: MariaDB/server#3726

Signed-off-by: Eric Herman <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
External Contribution All PRs from entities outside of MariaDB Foundation, Corporation, Codership agreements.
Development

Successfully merging this pull request may close these issues.

4 participants