[MDEV-14114] MS: Introduce a variable to init binlog cache size Created: 2017-10-24  Updated: 2017-11-17  Resolved: 2017-11-17

Status: Closed
Project: MariaDB Server
Component/s: Replication
Fix Version/s: 10.3.3

Type: Task Priority: Major
Reporter: Sergey Vojtovich Assignee: Vladislav Vaintroub
Resolution: Fixed Votes: 0
Labels: contribution, foundation

Sprint: 10.3.3-1

 Description   

From f8ea0478200bf115cb0abdbf28cdf339e268a0f6 Mon Sep 17 00:00:00 2001
From: Hanzhi Wang <hanzhiwa@microsoft.com>
Date: Wed, 13 Sep 2017 07:13:49 +0000
Subject: [PATCH] Merged PR 60892: Introduce a variable to init binlog cache
 size
 
Introduce a variable to init binlog cache size
 
Related work items: #84138
---
 mysql-test/r/mysqld--help-win.result | 3 +++
 sql/binlog.cc                        | 2 +-
 sql/mysqld.cc                        | 1 +
 sql/mysqld.h                         | 1 +
 sql/sys_vars.cc                      | 8 ++++++++
 5 files changed, 14 insertions(+), 1 deletion(-)
 
diff --git a/mysql-test/r/mysqld--help-win.result b/mysql-test/r/mysqld--help-win.result
index a6f2ae76188..e866f63c5a7 100644
--- a/mysql-test/r/mysqld--help-win.result
+++ b/mysql-test/r/mysqld--help-win.result
@@ -102,6 +102,8 @@ The following options may be given as the first argument:
  --binlog-ignore-db=name
  Tells the master that updates to the given database
  should not be logged to the binary log.
+ --binlog-init-cache-size=#
+ The size of init malloc cache for the binary log.
  --binlog-max-flush-queue-time=#
  The maximum time that the binary log group commit will
  keep reading transactions before it flush the
@@ -1084,6 +1086,7 @@ binlog-direct-non-transactional-updates FALSE
 binlog-error-action IGNORE_ERROR
 binlog-format STATEMENT
 binlog-gtid-simple-recovery FALSE
+binlog-init-cache-size 16384
 binlog-max-flush-queue-time 0
 binlog-order-commits TRUE
 binlog-row-event-max-size 8192
diff --git a/sql/binlog.cc b/sql/binlog.cc
index 8d3cb51b429..f092d283e73 100644
--- a/sql/binlog.cc
+++ b/sql/binlog.cc
@@ -1951,7 +1951,7 @@ File open_binlog_file(IO_CACHE *log, const char *log_file_name, const char **err
     *errmsg = "Could not open log file";
     goto err;
   }
-  if (init_io_cache(log, file, IO_SIZE*2, READ_CACHE, 0, 0,
+  if (init_io_cache(log, file, binlog_init_cache_size, READ_CACHE, 0, 0,
                     MYF(MY_WME|MY_DONT_CHECK_FILESIZE)))
   {
     sql_print_error("Failed to create a cache on log (file '%s')",
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index eba6fdec801..03839e6e742 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -562,6 +562,7 @@ ulonglong slave_rows_search_algorithms_options;
 #ifndef DBUG_OFF
 uint slave_rows_last_search_algorithm_used;
 #endif
+ulong binlog_init_cache_size=0;
 ulong binlog_cache_size=0;
 ulonglong  max_binlog_cache_size=0;
 ulong slave_max_allowed_packet= 0;
diff --git a/sql/mysqld.h b/sql/mysqld.h
index d814a8ff28a..e73c1c00230 100644
--- a/sql/mysqld.h
+++ b/sql/mysqld.h
@@ -236,6 +236,7 @@ extern my_bool log_bin_use_v1_row_events;
 extern ulong what_to_log,flush_time;
 extern ulong max_prepared_stmt_count, prepared_stmt_count;
 extern ulong open_files_limit;
+extern ulong binlog_init_cache_size;
 extern ulong binlog_cache_size, binlog_stmt_cache_size;
 extern ulonglong max_binlog_cache_size, max_binlog_stmt_cache_size;
 extern int32 opt_binlog_max_flush_queue_time;
diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc
index 236afb2d356..3108cbfc5b5 100644
--- a/sql/sys_vars.cc
+++ b/sql/sys_vars.cc
@@ -602,6 +602,14 @@ static bool fix_binlog_stmt_cache_size(sys_var *self, THD *thd, enum_var_type ty
   return false;
 }
 
+static Sys_var_ulong Sys_binlog_init_cache_size(
+       "binlog_init_cache_size", "The size of init malloc cache for the binary log.",
+       GLOBAL_VAR(binlog_init_cache_size),
+       CMD_LINE(REQUIRED_ARG),
+       VALID_RANGE(IO_SIZE*2, ULONG_MAX), DEFAULT(IO_SIZE*4), BLOCK_SIZE(IO_SIZE),
+       NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0),
+       ON_UPDATE(0));
+
 static Sys_var_ulong Sys_binlog_cache_size(
        "binlog_cache_size", "The size of the transactional cache for "
        "updates to transactional engines for the binary log. "



 Comments   
Comment by Sergey Vojtovich [ 2017-10-24 ]

Note that default value was increased from IO_SIZE * 2 to IO_SIZE * 4. It would be nice if Elkin could review this as well.

Comment by Jun Su [ 2017-11-13 ]

Change looks good to me. One minor text change:
"binlog_init_cache_size", "The size of init malloc cache for the binary log.",
change to :
"binlog_init_cache_size", "The initial cache size for reading the binary log.",

Comment by Vladislav Vaintroub [ 2017-11-13 ]

junsu the commit actually uses binlog_file_cache_size, as proposed by Elkin

Comment by Jun Su [ 2017-11-13 ]

Contribution is contributed under BSD-new license.

Generated at Thu Feb 08 08:11:01 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.