Skip to content

Commit

Permalink
Make IO_SIZE compile-time configurable
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
ericherman committed Jan 3, 2025
1 parent 3f865fe commit 9879b3d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,10 @@ ELSE()
SET (SKIP_COMPONENTS "N-O-N-E")
ENDIF()

SET(IO_SIZE "" CACHE STRING "Specify the I/O buffer size")
IF(IO_SIZE)
ADD_DEFINITIONS(-DIO_SIZE=${IO_SIZE})
ENDIF()

SET(MEMPROTECT_DEFAULT ON)

Expand Down
2 changes: 2 additions & 0 deletions include/my_global.h
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,9 @@ typedef SOCKET_SIZE_TYPE size_socket;
This influences the speed of the isam btree library. E.g.: too big too slow.
4096 is a common block size on SSDs.
*/
#ifndef IO_SIZE
#define IO_SIZE 4096U
#endif
#if (IO_SIZE < 512) || (IO_SIZE & (IO_SIZE-1))
#error "IO_SIZE must be a positive multiple of 512 and power of 2"
#endif
Expand Down

0 comments on commit 9879b3d

Please sign in to comment.