Skip to content
/ server Public

Commit 494fc45

Browse files
committed
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: mariadb-corporation/mariadb-connector-c#265 Signed-off-by: Eric Herman <[email protected]>
1 parent 16967b9 commit 494fc45

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,10 @@ ELSE()
193193
SET (SKIP_COMPONENTS "N-O-N-E")
194194
ENDIF()
195195

196+
SET(IO_SIZE "" CACHE STRING "Specify the I/O buffer size")
197+
IF(IO_SIZE)
198+
ADD_DEFINITIONS(-DIO_SIZE=${IO_SIZE})
199+
ENDIF()
196200

197201
SET(MEMPROTECT_DEFAULT ON)
198202

include/my_global.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -676,8 +676,10 @@ typedef SOCKET_SIZE_TYPE size_socket;
676676
This influences the speed of the isam btree library. E.g.: too big too slow.
677677
4096 is a common block size on SSDs.
678678
*/
679+
#ifndef IO_SIZE
679680
#define IO_SIZE 4096U
680-
#if ((IO_SIZE <= 0) || ((IO_SIZE % 512) != 0) || ((IO_SIZE & (IO_SIZE-1)) != 0))
681+
#endif
682+
#if (IO_SIZE < 512) || (IO_SIZE & (IO_SIZE-1))
681683
#error "IO_SIZE must be a positive multiple of 512 and power of 2"
682684
#endif
683685

0 commit comments

Comments
 (0)