Bug 91872 - make SAL_INFO and friends more efficient ...
Summary: make SAL_INFO and friends more efficient ...
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: sdk (show other bugs)
Version:
(earliest affected)
unspecified
Hardware: Other All
: medium normal
Assignee: Arnold Dumas
URL:
Whiteboard: target:5.4.0
Keywords: difficultyBeginner, easyHack, skillCpp, topicCleanup
Depends on:
Blocks:
 
Reported: 2015-06-05 10:42 UTC by Michael Meeks
Modified: 2017-02-14 08:57 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Meeks 2015-06-05 10:42:35 UTC
Almost all profiles I see of dbgutil builds have lots of time spent in constructing and then discarding SAL_INFO type output via nested stream operators, a with lots of allocation & freeing going on too. That is true even when (as in the normal case) none of that information is actually output.

It would be great to fix this by exposing the function:

sal/osl/all/log.cxx:
    bool report(sal_detail_LogLevel level, char const * area)

and giving it a sensible extern "C" name and wrapper eg. sal_detail_log_report - I suspect that will need a punch-through in the sal/ map file too checkout:

sal/util/sal.map

Then we should tweak the macros in the log headers:

#define SAL_DETAIL_LOG_STREAM(condition, level, area, where, stream) \
    do { \
        if (condition) { \

(and friends) to do:

        if ((condition) && sal_detail_log_report((level),(area))) { \ ...

instead - and (hopefully) hey-presto we save doing a ton of function calling just to discard the result.

For bonus points we should create a wrapper of __builtin_expect - eg. SAL_UNLIKELY or SAL_LIKELY etc. to ensure that this code is annotated as ~never happening and thus piled up in some section elsewhere so it has a far smaller icache impact too =)
 
Thanks !
Comment 1 Stephan Bergmann 2015-06-05 11:59:58 UTC
Whether SAL_INFO generates code is controlled at build time with SAL_LOG_INFO macro (see solenv/gbuild/gbuild.mk for setting it).  If it generates code, whether it generates output is controlled at runtime via SAL_LOG environment variable.

Thus, if you want to reduce code size in your --enable-dbgutil build (and am sure you don't want to enable any SAL_INFO output), tweak the setting of the SAL_LOG_INFO macro in solenv/gbuild/gbuild.mk accordingly.
Comment 2 Michael Meeks 2015-06-05 15:02:38 UTC
I saw the macros =) the ideal is to have the logging in-place, but have it burn much less CPU time so a better un-configured default (hopefully).
Comment 3 Stephan Bergmann 2015-06-08 06:42:48 UTC
Yes, comment 1 was meant to be complementary to comment 0.
Comment 4 Robinson Tryon (qubit) 2015-12-10 11:41:05 UTC Comment hidden (obsolete)
Comment 5 Robinson Tryon (qubit) 2016-02-18 14:52:11 UTC Comment hidden (obsolete)
Comment 6 Arnold Dumas 2017-01-31 20:55:17 UTC
Working on it
Comment 7 Commit Notification 2017-02-03 10:55:56 UTC
Arnold Dumas committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=b3a11c8f4f307bbbb597c9c6e7e61ee93e794873

tdf#91872: Make SAL_INFO and friends more efficient

It will be available in 5.4.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 8 Arnold Dumas 2017-02-13 09:32:12 UTC
I think this bug can be marked as FIXED, because SAL_LIKELY and SAL_UNLIKELY have already been defined in e75406e54c57fc3113d4f1983249eb2aec0a3bcd.