From bf35deda09f18f5c7f3179ace731a2a186e05445 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Tue, 3 Jan 2017 15:38:09 +0200 Subject: MDEV-11713 Optimize DBUG_PRINT and introduce DBUG_LOG MariaDB Server is unnecessarily evaluating the arguments of DBUG_PRINT() macros when the label is not defined. The macro DBUG_LOG() for C++ operator<< output which was added for InnoDB diagnostics in MySQL 5.7 is missing from MariaDB. Unlike the MySQL 5.7 implementation, MariaDB will avoid allocating and initializing the output string when the label is not defined. Introduce DBUG_OUT("crypt") and DBUG_OUT("checksum") for some InnoDB diagnostics, replacing some use of ib::info(). --- dbug/dbug.c | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) (limited to 'dbug') diff --git a/dbug/dbug.c b/dbug/dbug.c index b2b298beb09..048e4803b1a 100644 --- a/dbug/dbug.c +++ b/dbug/dbug.c @@ -1213,7 +1213,7 @@ void _db_return_(struct _db_stack_frame_ *_stack_frame_) * * SYNOPSIS * - * VOID _db_pargs_(_line_, keyword) + * int _db_pargs_(_line_, keyword) * int _line_; * char *keyword; * @@ -1226,12 +1226,14 @@ void _db_return_(struct _db_stack_frame_ *_stack_frame_) * */ -void _db_pargs_(uint _line_, const char *keyword) +int _db_pargs_(uint _line_, const char *keyword) { CODE_STATE *cs; - get_code_state_or_return; + get_code_state_or_return 0; cs->u_line= _line_; cs->u_keyword= keyword; + + return DEBUGGING && _db_keyword_(cs, cs->u_keyword, 0); } @@ -1265,27 +1267,24 @@ void _db_doprnt_(const char *format,...) { va_list args; CODE_STATE *cs; + int save_errno; + get_code_state_or_return; va_start(args,format); if (!cs->locked) pthread_mutex_lock(&THR_LOCK_dbug); - if (_db_keyword_(cs, cs->u_keyword, 0)) - { - int save_errno=errno; - DoPrefix(cs, cs->u_line); - if (TRACING) - Indent(cs, cs->level + 1); - else - (void) fprintf(cs->stack->out_file->file, "%s: ", cs->func); - (void) fprintf(cs->stack->out_file->file, "%s: ", cs->u_keyword); - DbugVfprintf(cs->stack->out_file->file, format, args); - DbugFlush(cs); - errno=save_errno; - } - else if (!cs->locked) - pthread_mutex_unlock(&THR_LOCK_dbug); + save_errno=errno; + DoPrefix(cs, cs->u_line); + if (TRACING) + Indent(cs, cs->level + 1); + else + (void) fprintf(cs->stack->out_file->file, "%s: ", cs->func); + (void) fprintf(cs->stack->out_file->file, "%s: ", cs->u_keyword); + DbugVfprintf(cs->stack->out_file->file, format, args); + DbugFlush(cs); + errno=save_errno; va_end(args); } -- cgit v1.2.1