List:Internals« Previous MessageNext Message »
From:Toshikuni Fukaya Date:December 26 2012 7:23am
Subject:[PATCH] use fallocate to create table
View as plain text  
Dear all,

I made a patch for MySQL 5.5.28 to speed up InnoDB table space creation.
I noticed that there are slow I/Os (consisting of many zero-fill writes
and syncs) when creating tables.

Linux kernels have the fallocate(2) system call, which guarantees that a
given file region is zeroed and yields a performance improvement on
supporting file systems.

I measured a 10% speed up in table space creation in our application.

Could you please accept my patch? If there is anything further I should
do for this patch, please advise me.

Regards,
Toshikuni Fukaya

diff -Naru mysql-5.5.28.orig/config.h.cmake mysql-5.5.28/config.h.cmake
--- mysql-5.5.28.orig/config.h.cmake	2012-12-26 13:10:18.641714214 +0900
+++ mysql-5.5.28/config.h.cmake	2012-12-26 13:11:07.325102180 +0900
@@ -206,6 +206,7 @@
 #cmakedefine HAVE_POLL 1
 #cmakedefine HAVE_PORT_CREATE 1
 #cmakedefine HAVE_POSIX_FALLOCATE 1
+#cmakedefine HAVE_FALLOCATE 1
 #cmakedefine HAVE_PREAD 1
 #cmakedefine HAVE_PAUSE_INSTRUCTION 1
 #cmakedefine HAVE_FAKE_PAUSE_INSTRUCTION 1
diff -Naru mysql-5.5.28.orig/configure.cmake mysql-5.5.28/configure.cmake
--- mysql-5.5.28.orig/configure.cmake	2012-12-26 13:10:18.641714214 +0900
+++ mysql-5.5.28/configure.cmake	2012-12-26 13:24:59.554639639 +0900
@@ -387,6 +387,7 @@
 CHECK_FUNCTION_EXISTS (poll HAVE_POLL)
 CHECK_FUNCTION_EXISTS (port_create HAVE_PORT_CREATE)
 CHECK_FUNCTION_EXISTS (posix_fallocate HAVE_POSIX_FALLOCATE)
+CHECK_FUNCTION_EXISTS (fallocate HAVE_FALLOCATE)
 CHECK_FUNCTION_EXISTS (pread HAVE_PREAD)
 CHECK_FUNCTION_EXISTS (pthread_attr_create HAVE_PTHREAD_ATTR_CREATE)
 CHECK_FUNCTION_EXISTS (pthread_attr_getstacksize HAVE_PTHREAD_ATTR_GETSTACKSIZE)
diff -Naru mysql-5.5.28.orig/storage/innobase/os/os0file.c mysql-5.5.28/storage/innobase/os/os0file.c
--- mysql-5.5.28.orig/storage/innobase/os/os0file.c	2012-12-26 13:10:18.709713360 +0900
+++ mysql-5.5.28/storage/innobase/os/os0file.c	2012-12-26 16:17:41.531929631 +0900
@@ -1957,6 +1957,12 @@
 	current_size = 0;
 	desired_size = (ib_int64_t)size + (((ib_int64_t)size_high) << 32);
 
+#ifdef HAVE_FALLOCATE
+	if (fallocate(file, 0, 0, desired_size == 0)) {
+		return (TRUE);
+	}
+#endif
+
 	/* Write up to 1 megabyte at a time. */
 	buf_size = ut_min(64, (ulint) (desired_size / UNIV_PAGE_SIZE))
 		* UNIV_PAGE_SIZE;
Thread
[PATCH] use fallocate to create tableToshikuni Fukaya26 Dec
  • Re: [PATCH] use fallocate to create tableToshikuni Fukaya26 Dec
    • Re: [PATCH] use fallocate to create tableSveta Smirnova27 Dec
      • Re: [PATCH] use fallocate to create tableSergei Golubchik28 Dec
        • Re: [PATCH] use fallocate to create tableSveta Smirnova28 Dec
          • Re: [PATCH] use fallocate to create tableToshikuni Fukaya16 Jan