From ddad018b66633c98100cf29ac0f86630b5417d7e Mon Sep 17 00:00:00 2001 From: Eric Herman Date: Tue, 31 Dec 2024 17:31:42 +0100 Subject: [PATCH] Make IO_SIZE configurable 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: https://github.com/mariadb-corporation/mariadb-connector-c/pull/265 Signed-off-by: Eric Herman --- CMakeLists.txt | 4 ++++ include/my_global.h | 2 ++ 2 files changed, 6 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6706779a91d84..6e829bd518a7e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/include/my_global.h b/include/my_global.h index 76ec2f813083e..5b349904fbfc5 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -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