Skip to content

Commit 959e2d3

Browse files
AliSQLAliSQL
authored andcommitted
[Perf] Issue#24 SPLIT LOG BUFFER TO ROTATE LOG WRITE
Description: ------------ It included two kinds of optimization for log write: 1. Split the log buffer into the two buffer that has the same size with innodb_log_buffer_size. So that when log_write_up_to_lsn occured, the mtr commit can write private log into another global log buffer. 2. Split log_sys->mutex into two mutex. log_sys->mutex protect the log buffer. log_sys->w_mutex protect log file. Those optimization can reduce the log write conflict and improve throughout.
1 parent d7764b5 commit 959e2d3

8 files changed

Lines changed: 139 additions & 100 deletions

File tree

mysql-test/suite/innodb/r/monitor.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ log_lsn_checkpoint_age disabled
150150
log_lsn_buf_pool_oldest disabled
151151
log_max_modified_age_async disabled
152152
log_max_modified_age_sync disabled
153-
log_pending_log_writes disabled
153+
log_pending_log_flushes disabled
154154
log_pending_checkpoint_writes disabled
155155
log_num_log_io disabled
156156
log_waits disabled

storage/innobase/handler/ha_innodb.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,7 @@ static PSI_mutex_info all_innodb_mutexes[] = {
308308
{&server_mutex_key, "server_mutex", 0},
309309
# endif /* !HAVE_ATOMIC_BUILTINS */
310310
{&log_sys_mutex_key, "log_sys_mutex", 0},
311+
{&log_sys_w_mutex_key, "log_sys_w_mutex", 0},
311312
# ifdef UNIV_MEM_DEBUG
312313
{&mem_hash_mutex_key, "mem_hash_mutex", 0},
313314
# endif /* UNIV_MEM_DEBUG */

storage/innobase/include/log0log.h

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -763,6 +763,7 @@ struct log_t{
763763
buffer */
764764
#ifndef UNIV_HOTBACKUP
765765
ib_mutex_t mutex; /*!< mutex protecting the log */
766+
ib_mutex_t w_mutex; /*!< mutex to protect log file */
766767

767768
ib_mutex_t log_flush_order_mutex;/*!< mutex to serialize access to
768769
the flush list when we are putting
@@ -773,8 +774,9 @@ struct log_t{
773774
insertions in the flush_list happen
774775
in the LSN order. */
775776
#endif /* !UNIV_HOTBACKUP */
776-
byte* buf_ptr; /* unaligned log buffer */
777777
byte* buf; /*!< log buffer */
778+
byte* buf_pair_ptr[2];/*!< unaligned log buffer */
779+
byte* buf_pair[2]; /*!< two buffer for redo copy/write */
778780
ulint buf_size; /*!< log buffer size in bytes */
779781
ulint max_buf_free; /*!< recommended maximum value of
780782
buf_free, after which the buffer is
@@ -812,11 +814,6 @@ struct log_t{
812814
volatile bool is_extending; /*!< this is set to true during extend
813815
the log buffer size */
814816
lsn_t write_lsn; /*!< last written lsn */
815-
ulint write_end_offset;/*!< the data in buffer has
816-
been written up to this offset
817-
when the current write ends:
818-
this field will then be copied
819-
to buf_next_to_write */
820817
lsn_t current_flush_lsn;/*!< end lsn for the current running
821818
write + flush operation */
822819
lsn_t flushed_to_disk_lsn;
@@ -937,6 +934,16 @@ struct log_t{
937934
mutex_exit(&log_sys->log_flush_order_mutex); \
938935
} while (0)
939936

937+
#define log_mutex_enter_all() do { \
938+
mutex_enter(&log_sys->w_mutex); \
939+
mutex_enter(&log_sys->mutex); \
940+
} while (0)
941+
942+
#define log_mutex_exit_all() do { \
943+
mutex_exit(&log_sys->w_mutex); \
944+
mutex_exit(&log_sys->mutex); \
945+
} while (0)
946+
940947
#ifdef UNIV_LOG_ARCHIVE
941948
/** Archiving state @{ */
942949
#define LOG_ARCH_ON 71

storage/innobase/include/sync0sync.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ extern mysql_pfs_key_t ibuf_bitmap_mutex_key;
7979
extern mysql_pfs_key_t ibuf_mutex_key;
8080
extern mysql_pfs_key_t ibuf_pessimistic_insert_mutex_key;
8181
extern mysql_pfs_key_t log_sys_mutex_key;
82+
extern mysql_pfs_key_t log_sys_w_mutex_key;
8283
extern mysql_pfs_key_t log_flush_order_mutex_key;
8384
# ifndef HAVE_ATOMIC_BUILTINS
8485
extern mysql_pfs_key_t server_mutex_key;
@@ -702,6 +703,7 @@ or row lock! */
702703
#define SYNC_TRX_SYS_HEADER 290
703704
#define SYNC_PURGE_QUEUE 200
704705
#define SYNC_LOG 170
706+
#define SYNC_WRITE_LOG 171
705707
#define SYNC_LOG_FLUSH_ORDER 147
706708
#define SYNC_RECV 168
707709
#define SYNC_FTS_TOKENIZE 167

0 commit comments

Comments
 (0)