Skip to content
/ server Public

Commit 5a19920

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 matches 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. See also: mariadb-corporation/mariadb-connector-c#267 Signed-off-by: Eric Herman <[email protected]>
1 parent a40231e commit 5a19920

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,15 @@ ELSE()
191191
SET (SKIP_COMPONENTS "N-O-N-E")
192192
ENDIF()
193193

194+
# I/O buffer size. May be smaller than the disk page size.
195+
# 4096 is a common block size on SSDs.
196+
# This influences the speed of the isam btree library.
197+
# E.g.: too big may become too slow.
198+
SET(IO_SIZE 4096 CACHE STRING "Specify the I/O buffer size")
199+
math(EXPR is_power_of_two "(${IO_SIZE} & (${IO_SIZE} - 1))")
200+
IF(IO_SIZE LESS 512 OR NOT is_power_of_two EQUAL 0)
201+
message(FATAL_ERROR "IO_SIZE ${IO_SIZE} must >= 512 and a power of 2.")
202+
ENDIF()
194203

195204
SET(MEMPROTECT_DEFAULT ON)
196205

config.h.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -551,3 +551,5 @@ this is the case with Microsoft Windows VirtualFree(MEM_DECOMMIT) */
551551
#endif
552552

553553
#cmakedefine HAVE_VFORK 1
554+
555+
#cmakedefine IO_SIZE @IO_SIZE@

include/my_global.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -664,17 +664,6 @@ typedef SOCKET_SIZE_TYPE size_socket;
664664
#define OS_FILE_LIMIT UINT_MAX
665665
#endif
666666

667-
/*
668-
I/O buffer size. May be smaller than the disk page size.
669-
This influences the speed of the isam btree library.
670-
E.g.: too big may become too slow.
671-
4096 is a common block size on SSDs.
672-
*/
673-
#define IO_SIZE 4096U
674-
#if (IO_SIZE < 512) || (IO_SIZE & (IO_SIZE-1))
675-
#error "IO_SIZE must be a positive multiple of 512 and power of 2"
676-
#endif
677-
678667
/*
679668
How much overhead does malloc/my_malloc have. The code often allocates
680669
something like 1024-MALLOC_OVERHEAD bytes

0 commit comments

Comments
 (0)