common: implement bt_common_g_string_append_printf
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 19 Jun 2019 18:21:57 +0000 (14:21 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Sun, 21 Jul 2019 15:39:24 +0000 (11:39 -0400)
commit5ab3582ba148e9e5c7c86bd277b6bdbd56465bbd
treee402ce29f09009d8b637e3e37a2a306947b24da4
parent8577d366b65ce03c40e8484a243ca32eb6b6781e
common: implement bt_common_g_string_append_printf

g_string_append_printf() internally allocates a temporary buffer
through use of vasnprintf for each call. This clearly appears at
the top of perf report.

Implement our own private bt_g_string_append_printf which operates
directly on the GString buffer.

See proof of memory allocation/free near the top of this perf report
when converting a 400M LTTng trace to text (piped to /dev/null):

  14.76%  babeltrace2  libc-2.24.so                [.] vfprintf
   7.92%  babeltrace2  [kernel.kallsyms]           [k] vmacache_find
   6.39%  babeltrace2  libglib-2.0.so.0.5000.3     [.] g_string_insert_len
   4.77%  babeltrace2  babeltrace-plugin-ctf.so    [.] bt_bfcr_start
   4.23%  babeltrace2  libc-2.24.so                [.] _int_malloc
   4.06%  babeltrace2  libc-2.24.so                [.] _IO_default_xsputn
   3.60%  babeltrace2  libc-2.24.so                [.] strlen
   3.60%  babeltrace2  libc-2.24.so                [.] __strchrnul
   3.60%  babeltrace2  libbabeltrace2.so.0.0.0     [.] bt_attributes_borrow_field_by_name
   3.51%  babeltrace2  libc-2.24.so                [.] _int_free
   2.88%  babeltrace2  libc-2.24.so                [.] __vasprintf_chk
   2.88%  babeltrace2  libc-2.24.so                [.] _IO_str_init_static_internal
   2.88%  babeltrace2  libc-2.24.so                [.] __strcmp_sse2_unaligned
   2.16%  babeltrace2  libc-2.24.so                [.] malloc
   2.16%  babeltrace2  libc-2.24.so                [.] __tzstring_len

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I956305ac8891d244dbdab6a5b0dde82ecc960e25
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1514
CI-Build: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
src/common/common.c
src/common/common.h
This page took 0.024858 seconds and 4 git commands to generate.