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)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 7 Aug 2019 18:05:18 +0000 (14:05 -0400)
commitb57e7beddb0e63a8da3356ec77f938a71d0f4484
tree7fae246301de5bf259efa906cd91c869cc5078e4
parent6e5e1b5392a0b4d3868969cd8a5b36d00cadf729
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.025357 seconds and 4 git commands to generate.