From 9879b3ddcdf0a7f587d5ef5c038b86b197379c25 Mon Sep 17 00:00:00 2001 From: Eric Herman Date: Tue, 31 Dec 2024 17:31:42 +0100 Subject: [PATCH] Make IO_SIZE compile-time configurable 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: 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 f1ec92301ee9d..bbdaff53c7b86 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 < 512) || (IO_SIZE & (IO_SIZE-1)) #error "IO_SIZE must be a positive multiple of 512 and power of 2" #endif