diff options
author | Monty <monty@mariadb.org> | 2017-08-06 21:53:49 +0300 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2017-08-24 01:05:52 +0200 |
commit | b6c5657ef27de034439b1505a8b4815c263d6455 (patch) | |
tree | a0bcef3957b1e7f5f7e8423f245ffce97f5e6ae5 /sql | |
parent | ffb17a6509168c34465f4d3b0605a3b4198c05ef (diff) | |
download | mariadb-git-b6c5657ef27de034439b1505a8b4815c263d6455.tar.gz |
Reduce stack size
WSREP_LOG increased the stack size of all function, where it was used,
with 1024 bytes, even if it would never called. What's worse is that one
a Mac with Lion 10.7, the stack size was increased with 1024* number of
calls per function.
By moving WSREP_LOG() to a function, the stack size on Lion in function
mysql_execute() was reduced from 18K to 12K. On my main Linux machine
with gcc 5.4 the reduction was from 5k to 4k.
Diffstat (limited to 'sql')
-rw-r--r-- | sql/wsrep_mysqld.cc | 11 | ||||
-rw-r--r-- | sql/wsrep_mysqld.h | 9 |
2 files changed, 13 insertions, 7 deletions
diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc index 2854a9b162a..947492e2b73 100644 --- a/sql/wsrep_mysqld.cc +++ b/sql/wsrep_mysqld.cc @@ -246,6 +246,17 @@ static void wsrep_log_cb(wsrep_log_level_t level, const char *msg) { } } +void wsrep_log(void (*fun)(const char *, ...), const char *format, ...) +{ + va_list args; + char msg[1024]; + va_start(args, format); + vsnprintf(msg, sizeof(msg) - 1, format, args); + va_end(args); + (fun)("WSREP: %s", msg); +} + + static void wsrep_log_states (wsrep_log_level_t const level, const wsrep_uuid_t* const group_uuid, wsrep_seqno_t const group_seqno, diff --git a/sql/wsrep_mysqld.h b/sql/wsrep_mysqld.h index 7eae366df7a..fb46cda7019 100644 --- a/sql/wsrep_mysqld.h +++ b/sql/wsrep_mysqld.h @@ -192,13 +192,8 @@ extern wsrep_seqno_t wsrep_locked_seqno; ? wsrep_forced_binlog_format : (ulong)(my_format)) // prefix all messages with "WSREP" -#define WSREP_LOG(fun, ...) \ - do { \ - char msg[1024] = {'\0'}; \ - snprintf(msg, sizeof(msg) - 1, ## __VA_ARGS__); \ - fun("WSREP: %s", msg); \ - } while(0) - +void wsrep_log(void (*fun)(const char *, ...), const char *format, ...); +#define WSREP_LOG(fun, ...) wsrep_log(fun, ## __VA_ARGS__) #define WSREP_LOG_CONFLICT_THD(thd, role) \ WSREP_LOG(sql_print_information, \ "%s: \n " \ |