logging: use G_UNLIKELY in BT_LOG_ON macros
authorSimon Marchi <simon.marchi@efficios.com>
Sun, 22 May 2022 01:53:00 +0000 (21:53 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Wed, 15 Jun 2022 18:15:50 +0000 (14:15 -0400)
commit088b0bbe10be6143d390eff198c459cc03333650
tree336f6e38c78ead02b5a82a1a2865de0634f67bd7
parent3f9e6f1eeb6473a595acc1b2dfe71e08aa3b3890
logging: use G_UNLIKELY in BT_LOG_ON macros

Use G_UNLIKELY to hint the compiler (and the processor) that logging is
likely not going to be enabled.  We care about performance in the
logging disabled case more than in the logging enabled case.

I see a small but consistent speedup.  Not scientific (sample size of
2), but before it looks like:

    $ time ./src/cli/babeltrace2 /home/simark/lttng-traces/auto-20180226-075238 -o dummy
    ./src/cli/babeltrace2 /home/simark/lttng-traces/auto-20180226-075238 -o dummy  3.98s user 0.05s system 99% cpu 4.025 total
    $ time ./src/cli/babeltrace2 /home/simark/lttng-traces/auto-20180226-075238 -o dummy
    ./src/cli/babeltrace2 /home/simark/lttng-traces/auto-20180226-075238 -o dummy  3.96s user 0.04s system 99% cpu 4.000 total

And after:

    $ time ./src/cli/babeltrace2 /home/simark/lttng-traces/auto-20180226-075238 -o dummy
    ./src/cli/babeltrace2 /home/simark/lttng-traces/auto-20180226-075238 -o dummy  3.81s user 0.04s system 99% cpu 3.848 total
    $ time ./src/cli/babeltrace2 /home/simark/lttng-traces/auto-20180226-075238 -o dummy
    ./src/cli/babeltrace2 /home/simark/lttng-traces/auto-20180226-075238 -o dummy  3.77s user 0.04s system 100% cpu 3.806 total

This is with babeltrace configured with:

    --enable-python-bindings --enable-python-plugins --disable-man-pages 'CFLAGS=-gdwarf-5 -g3 -O2' 'CXXFLAGS=-gdwarf-5 -g3 -O2' --prefix=/tmp/babeltrace 'CC=ccache clang' 'CXX=ccache clang++'

Change-Id: I3b11d1023f4dfad9c88ffa24e98a07afccb8cc61
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8106
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
src/logging/log.h
This page took 0.02443 seconds and 4 git commands to generate.