Skip to content

Commit

Permalink
Make IO_SIZE configurable
Browse files Browse the repository at this point in the history
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;

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

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 Dec 31, 2024
1 parent 16967b9 commit ddad018
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 <= 0) || ((IO_SIZE % 512) != 0) || ((IO_SIZE & (IO_SIZE-1)) != 0))
#error "IO_SIZE must be a positive multiple of 512 and power of 2"
#endif
Expand Down

0 comments on commit ddad018

Please sign in to comment.