summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMonty <monty@mariadb.org>2020-07-16 12:45:30 +0300
committerMonty <monty@mariadb.org>2020-07-23 10:54:32 +0300
commit26824581281fcb2b2251585d8081de38d561ca93 (patch)
tree429a399fc66e8066f76864a7df5a66fa2c1ba623
parentc89e927a5675bd1e84a9c5dd02f5d649e829453e (diff)
downloadmariadb-git-26824581281fcb2b2251585d8081de38d561ca93.tar.gz
Use larger buffer when reading binary and relay logs
- Should speed up replication
-rw-r--r--sql/log.cc4
-rw-r--r--sql/log.h6
-rw-r--r--sql/rpl_rli.cc4
3 files changed, 11 insertions, 3 deletions
diff --git a/sql/log.cc b/sql/log.cc
index 5f4fd6bbcab..0bfe7d7ee8b 100644
--- a/sql/log.cc
+++ b/sql/log.cc
@@ -2828,7 +2828,9 @@ bool MYSQL_LOG::open(
else if ((seek_offset= mysql_file_tell(file, MYF(MY_WME))))
goto err;
- if (init_io_cache(&log_file, file, IO_SIZE, io_cache_type, seek_offset, 0,
+ if (init_io_cache(&log_file, file, (log_type == LOG_NORMAL ? IO_SIZE :
+ LOG_BIN_IO_SIZE),
+ io_cache_type, seek_offset, 0,
MYF(MY_WME | MY_NABP |
((log_type == LOG_BIN) ? MY_WAIT_IF_FULL : 0))))
goto err;
diff --git a/sql/log.h b/sql/log.h
index 063513fe908..58e681985eb 100644
--- a/sql/log.h
+++ b/sql/log.h
@@ -295,6 +295,12 @@ enum enum_log_type { LOG_UNKNOWN, LOG_NORMAL, LOG_BIN };
enum enum_log_state { LOG_OPENED, LOG_CLOSED, LOG_TO_BE_OPENED };
/*
+ Use larger buffers when reading from and to binary log
+ We make it one step smaller than 64K to account for malloc overhead.
+*/
+#define LOG_BIN_IO_SIZE MY_ALIGN_DOWN(65536-1, IO_SIZE)
+
+/*
TODO use mmap instead of IO_CACHE for binlog
(mmap+fsync is two times faster than write+fsync)
*/
diff --git a/sql/rpl_rli.cc b/sql/rpl_rli.cc
index 11eccefdde9..941616a26d5 100644
--- a/sql/rpl_rli.cc
+++ b/sql/rpl_rli.cc
@@ -268,7 +268,7 @@ a file name for --relay-log-index option", opt_relaylog_index_name);
msg= current_thd->get_stmt_da()->message();
goto err;
}
- if (init_io_cache(&info_file, info_fd, IO_SIZE*2, READ_CACHE, 0L,0,
+ if (init_io_cache(&info_file, info_fd, LOG_BIN_IO_SIZE, READ_CACHE, 0L,0,
MYF(MY_WME)))
{
sql_print_error("Failed to create a cache on relay log info file '%s'",
@@ -303,7 +303,7 @@ Failed to open the existing relay log info file '%s' (errno %d)",
error= 1;
}
else if (init_io_cache(&info_file, info_fd,
- IO_SIZE*2, READ_CACHE, 0L, 0, MYF(MY_WME)))
+ LOG_BIN_IO_SIZE, READ_CACHE, 0L, 0, MYF(MY_WME)))
{
sql_print_error("Failed to create a cache on relay log info file '%s'",
fname);