pgbackrest.git / summary / log / commit / refs

commit    f819a32cdf94bc799a4902ab6aaa559cd11d4ef8
Author:   David Steele <david@pgmasters.net>
Date:     Sat May 11 11:57:49 2019 +0000

    Improve efficiency of FUNCTION_LOG*() macros.
    
    Call stackTraceTestStop()/stackTraceTestStart() once per block instead of with every param call.  This was done to be cautious but is not necessary and slows down development.
    
    These functions were never built into production so had no impact there.


doc/xml/release.xml | 4 ++++ src/common/debug.h | 33 +++++++++------------------------ 2 files changed, 13 insertions(+), 24 deletions(-) diff --git a/doc/xml/release.xml b/doc/xml/release.xml index cd2886615..4720d0b8e 100644 --- a/doc/xml/release.xml +++ b/doc/xml/release.xml @@ -158,6 +158,10 @@ <release-item> <p>Use <code>THROW_ON_SYS_ERROR*()</code> to improve code coverage.</p> </release-item> + + <release-item> + <p>Improve efficiency of <code>FUNCTION_LOG*()</code> macros.</p> + </release-item> </release-development-list> </release-core-list> diff --git a/src/common/debug.h b/src/common/debug.h index 6f362efd6..2f5bccab5 100644 --- a/src/common/debug.h +++ b/src/common/debug.h @@ -34,36 +34,29 @@ level is set to debug or trace. #define FUNCTION_LOG_LEVEL() \ FUNCTION_LOG_logLevel -#ifdef DEBUG +#ifdef DEBUG_TEST_TRACE #define FUNCTION_LOG_BEGIN_BASE(logLevel) \ LogLevel FUNCTION_LOG_LEVEL() = STACK_TRACE_PUSH(logLevel); \ \ { \ - stackTraceParamLog(); + stackTraceParamLog(); \ + stackTraceTestStop(); #define FUNCTION_LOG_END_BASE() \ + stackTraceTestStart(); \ LOG_WILL(FUNCTION_LOG_LEVEL(), 0, "(%s)", stackTraceParam()); \ } - - #define FUNCTION_LOG_PARAM_BASE_BEGIN() \ - stackTraceTestStop() \ - - #define FUNCTION_LOG_PARAM_BASE_END() \ - stackTraceTestStart() #else #define FUNCTION_LOG_BEGIN_BASE(logLevel) \ LogLevel FUNCTION_LOG_LEVEL() = STACK_TRACE_PUSH(logLevel); \ \ if (logWill(FUNCTION_LOG_LEVEL())) \ { \ - stackTraceParamLog() + stackTraceParamLog(); #define FUNCTION_LOG_END_BASE() \ LOG(FUNCTION_LOG_LEVEL(), 0, "(%s)", stackTraceParam()); \ } - - #define FUNCTION_LOG_PARAM_BASE_BEGIN() - #define FUNCTION_LOG_PARAM_BASE_END() #endif /*********************************************************************************************************************************** @@ -82,15 +75,11 @@ FUNCTION_LOG_VOID() is provided as a shortcut for functions that have no paramet FUNCTION_LOG_END_BASE() #define FUNCTION_LOG_PARAM(typeMacroPrefix, param) \ - FUNCTION_LOG_PARAM_BASE_BEGIN(); \ - stackTraceParamAdd(FUNCTION_LOG_##typeMacroPrefix##_FORMAT(param, stackTraceParamBuffer(#param), STACK_TRACE_PARAM_MAX)); \ - FUNCTION_LOG_PARAM_BASE_END() + stackTraceParamAdd(FUNCTION_LOG_##typeMacroPrefix##_FORMAT(param, stackTraceParamBuffer(#param), STACK_TRACE_PARAM_MAX)) #define FUNCTION_LOG_PARAM_P(typeMacroPrefix, param) \ do \ { \ - FUNCTION_LOG_PARAM_BASE_BEGIN(); \ - \ char *buffer = stackTraceParamBuffer(#param); \ \ if (param == NULL) \ @@ -100,16 +89,12 @@ FUNCTION_LOG_VOID() is provided as a shortcut for functions that have no paramet buffer[0] = '*'; \ stackTraceParamAdd(FUNCTION_LOG_##typeMacroPrefix##_FORMAT(*param, buffer + 1, STACK_TRACE_PARAM_MAX - 1) + 1); \ } \ - \ - FUNCTION_LOG_PARAM_BASE_END(); \ } \ while(0) #define FUNCTION_LOG_PARAM_PP(typeMacroPrefix, param) \ do \ { \ - FUNCTION_LOG_PARAM_BASE_BEGIN(); \ - \ char *buffer = stackTraceParamBuffer(#param); \ \ if (param == NULL) \ @@ -122,8 +107,6 @@ FUNCTION_LOG_VOID() is provided as a shortcut for functions that have no paramet buffer[1] = '*'; \ stackTraceParamAdd(FUNCTION_LOG_##typeMacroPrefix##_FORMAT(**param, buffer + 2, STACK_TRACE_PARAM_MAX - 2) + 2); \ } \ - \ - FUNCTION_LOG_PARAM_BASE_END(); \ } \ while(0) @@ -293,7 +276,8 @@ test macros are compiled out. if (stackTraceTest()) \ { \ STACK_TRACE_PUSH(logLevelDebug); \ - stackTraceParamLog() + stackTraceParamLog(); \ + stackTraceTestStop() #define FUNCTION_TEST_PARAM(typeMacroPrefix, param) \ FUNCTION_LOG_PARAM(typeMacroPrefix, param) @@ -305,6 +289,7 @@ test macros are compiled out. FUNCTION_LOG_PARAM_PP(typeName, param) #define FUNCTION_TEST_END() \ + stackTraceTestStart(); \ } #define FUNCTION_TEST_VOID() \ [parent: 7e2f6a6a4365]