<font size=2 face="sans-serif">The macro is elegant and solves the problem
nicely.</font>
<br>
<br><font size=2 face="sans-serif">I find that it does not make the biggest
issue go away - the entire formatted string gets stored in the trace file
multiple times.</font>
<br>
<br><font size=2 face="sans-serif">The best solution would be:</font>
<ol>
<li value=1><font size=2 face="sans-serif">To modify CTF and define a type
that indicates a printf-style format string.</font>
<li value=2><font size=2 face="sans-serif">To have a LTTng macro that provides
this string to the tracer, so that it can record it <u>only once</u> in
the metadata.</font>
<li value=3><font size=2 face="sans-serif">To have the tracepoint store
all the arguments in binary form, possibly with the addition of some identifying
value of the format string.</font>
<li value=4><font size=2 face="sans-serif">And to have babeltrace (the
CTF trace reader) perform the formatting off-line.</font></ol>
<br><font size=2 face="sans-serif">I mean - consider a trace message that
includes a long format string, with say - 5 integer arguments. Something
like:</font>
<br><font size=2 face="sans-serif">"Buffer vacancy threshold warning:
curr_limit=%d, curr_threshold=%d, channel_num=%d, high_mark=%d, hit_count=%d"</font>
<br>
<br><font size=2 face="sans-serif">This stores > 105 bytes with <u>every</u>
trace line. But the real information here is only 20 bytes (assuming the
integers are 32-bits).</font>
<br>
<br><font size=2 face="sans-serif">Storing the format string once in the
metadata will effectively boost performance for a system trying to trace
like this.</font>
<br>
<br><font size=2 color=#000080 face="sans-serif">Amit Margalit</font>
<br><font size=2 color=#808000 face="sans-serif">IBM XIV </font><font size=2 face="sans-serif">-
<i>Storage Reinvented</i></font>
<br><font size=2 face="sans-serif">XIV-NAS Development Team</font>
<br><font size=2 face="sans-serif">Tel. 03</font><font size=2 face="Arial">-689-7774</font>
<br><font size=2 face="Arial">Fax. 03-689-7230</font>
<br>
<br>
<br>
<br><font size=1 color=#5f5f5f face="sans-serif">From:
</font><font size=1 face="sans-serif">Máté Ferenczy <mate.ferenczy@ericsson.com></font>
<br><font size=1 color=#5f5f5f face="sans-serif">To:
</font><font size=1 face="sans-serif">Mathieu Desnoyers <mathieu.desnoyers@efficios.com></font>
<br><font size=1 color=#5f5f5f face="sans-serif">Cc:
</font><font size=1 face="sans-serif">"lttng-dev@lists.lttng.org"
<lttng-dev@lists.lttng.org></font>
<br><font size=1 color=#5f5f5f face="sans-serif">Date:
</font><font size=1 face="sans-serif">12/12/2013 07:39 PM</font>
<br><font size=1 color=#5f5f5f face="sans-serif">Subject:
</font><font size=1 face="sans-serif">Re: [lttng-dev]
efficient use of LTTng in legacy codebase</font>
<br>
<hr noshade>
<br>
<br>
<br><font size=2 color=#004080 face="Calibri">That’s even better, as far
as I see we do not even have to touch the liblttng code itself.</font>
<br><font size=2 color=#004080 face="Calibri">Will get back with comments
if any after testing.</font>
<br><font size=2 color=#004080 face="Calibri"> </font>
<br><font size=2 color=#004080 face="Calibri">Thanks so much! </font>
<br><font size=2 color=#004080 face="Calibri">mate</font>
<br><font size=2 color=#004080 face="Calibri"> </font>
<br><font size=2 color=#004080 face="Calibri"> </font>
<br><font size=2 face="Tahoma"><b>From:</b> Mathieu Desnoyers [</font><a href=mailto:mathieu.desnoyers@efficios.com><font size=2 face="Tahoma">mailto:mathieu.desnoyers@efficios.com</font></a><font size=2 face="Tahoma">]
<b><br>
Sent:</b> Thursday, December 12, 2013 4:35 AM<b><br>
To:</b> Máté Ferenczy<b><br>
Cc:</b> lttng-dev@lists.lttng.org<b><br>
Subject:</b> Re: efficient use of LTTng in legacy codebase</font>
<br><font size=2 face="Calibri"> </font>
<br><font size=2 face="Calibri">Just to speed things up, please have a
look at the proposed UST patch. (it's not in mainline yet)</font>
<br><font size=2 face="Calibri"> </font>
<br><font size=2 face="Calibri">This is specifically for a demo program
example so far.</font>
<br><font size=2 face="Calibri"> </font>
<br><font size=2 face="Calibri">Comments are welcome,</font>
<br><font size=2 face="Calibri"> </font>
<br><font size=2 face="Calibri">Thanks,</font>
<br><font size=2 face="Calibri"> </font>
<br><font size=2 face="Calibri">Mathieu</font>
<br><font size=2 face="Calibri"> </font>
<br><font size=2 face="Calibri"> </font>
<div align=center>
<hr></div>
<br><font size=2 face="Helvetica"><b>From: </b>"Máté Ferenczy"
<</font><a href=mailto:mate.ferenczy@ericsson.com><font size=2 color=blue face="Helvetica"><u>mate.ferenczy@ericsson.com</u></font></a><font size=2 face="Helvetica">><b><br>
To: </b>"Mathieu Desnoyers" <</font><a href=mailto:mathieu.desnoyers@efficios.com><font size=2 color=blue face="Helvetica"><u>mathieu.desnoyers@efficios.com</u></font></a><font size=2 face="Helvetica">><b><br>
Cc: </b></font><a href="mailto:lttng-dev@lists.lttng.org"><font size=2 color=blue face="Helvetica"><u>lttng-dev@lists.lttng.org</u></font></a><font size=2 face="Helvetica"><b><br>
Sent: </b>Wednesday, December 11, 2013 8:52:30 PM<b><br>
Subject: </b>RE: efficient use of LTTng in legacy codebase</font>
<br><font size=2 face="Helvetica"> </font>
<br><font size=2 color=#004080 face="Calibri">It sounds great, I like the
idea. Just to make sure I understand your suggestion, are we talking about
converting the variable argument list to string in include/lttng/ust-tracepoint-event-write.h?</font>
<br><font size=2 color=#004080 face="Calibri"> </font>
<br><font size=2 color=#004080 face="Calibri">For example:</font>
<br><font size=2 color=#004080>#define ctf_format_string(_item, …)
\</font>
<br><font size=2 color=#004080> do {
\</font>
<br><font size=2 color=#004080>
char _buf[BUF_MAXLEN];
\</font>
<br><font size=2 color=#004080>
snprintf(buf, sizeof(_buf), __VA_ARGS__);
\</font>
<br><font size=2 color=#004080>
_ctf_string(_item, _buf, 0);
\</font>
<br><font size=2 color=#004080> } while(0)</font>
<br><font size=2 color=#004080> </font>
<br><font size=2 color=#004080 face="Calibri">Or do you have some better
place to put this logic?</font>
<br><font size=2 color=#004080 face="Calibri"> </font>
<br><font size=2 color=#004080 face="Calibri">Thanks,</font>
<br><font size=2 color=#004080 face="Calibri">Mate</font>
<br><font size=2 color=#004080 face="Calibri"> </font>
<br><font size=2 face="Tahoma"><b>From:</b> Mathieu Desnoyers [</font><a href=mailto:mathieu.desnoyers@efficios.com><font size=2 color=blue face="Tahoma"><u>mailto:mathieu.desnoyers@efficios.com</u></font></a><font size=2 face="Tahoma">]
<b><br>
Sent:</b> Wednesday, December 11, 2013 4:48 PM<b><br>
To:</b> Máté Ferenczy<b><br>
Cc:</b> </font><a href="mailto:lttng-dev@lists.lttng.org"><font size=2 color=blue face="Tahoma"><u>lttng-dev@lists.lttng.org</u></font></a><font size=2 face="Tahoma"><b><br>
Subject:</b> Re: efficient use of LTTng in legacy codebase</font>
<br><font size=2 face="Calibri"> </font>
<div align=center>
<hr></div>
<br><font size=2 face="Helvetica"><b>From: </b>"Máté Ferenczy"
<</font><a href=mailto:mate.ferenczy@ericsson.com target=_blank><font size=2 color=blue face="Helvetica"><u>mate.ferenczy@ericsson.com</u></font></a><font size=2 face="Helvetica">><b><br>
To: </b>"mathieu desnoyers" <</font><a href=mailto:mathieu.desnoyers@efficios.com target=_blank><font size=2 color=blue face="Helvetica"><u>mathieu.desnoyers@efficios.com</u></font></a><font size=2 face="Helvetica">><b><br>
Cc: </b></font><a href="mailto:lttng-dev@lists.lttng.org" target=_blank><font size=2 color=blue face="Helvetica"><u>lttng-dev@lists.lttng.org</u></font></a><font size=2 face="Helvetica"><b><br>
Sent: </b>Wednesday, December 11, 2013 6:52:22 PM<b><br>
Subject: </b>RE: efficient use of LTTng in legacy codebase</font>
<br><font size=2 face="Helvetica"> </font>
<br><font size=2 face="Calibri">I found this email thread: </font><a href="https://www.mail-archive.com/lttng-dev@lists.lttng.org/msg02278.html" target=_blank><font size=2 color=blue face="Calibri"><u>https://www.mail-archive.com/lttng-dev@lists.lttng.org/msg02278.html</u></font></a>
<br><font size=2 face="Calibri">According to this I could just check caa_unlikely(__tracepoint_##provider##___##name.state).
However, Dave claims that this state will stay true even if the tracepoint
is disabled. Is there anything else I should check for?</font>
<br><font size=3> </font>
<br><font size=3>I would recommend doing this in the UST probe provider
instead. Within the TRACEPOINT_EVENT "TP_FIELD" section, when
you declare your string field, you could parse the format string there
in the last argument of a ctf_string() (a statement expression). The format
string would be received as parameter by the tracepoint, along with a variable
arg list (...). In the probe, it would be turned into a va_list (see stdarg(3)),
and the parameters could be decoded into a string there. This has the benefit
of moving the serialization call out-of-line into the probe provider rather
than clobbering the tracepoint call site.</font>
<br><font size=3> </font>
<br><font size=3>Thoughts ?</font>
<br><font size=3> </font>
<br><font size=3>Thanks,</font>
<br><font size=3> </font>
<br><font size=3>Mathieu</font>
<br><font size=3> </font>
<br><font size=2 face="Calibri">Thanks,</font>
<br><font size=2 face="Calibri">Mate</font>
<br><font size=2 color=#004080 face="Calibri"> </font>
<br><font size=2 face="Tahoma"><b>From:</b> Máté Ferenczy <b><br>
Sent:</b> Wednesday, December 11, 2013 12:17 PM<b><br>
To:</b> 'mathieu.desnoyers@efficios.com'<b><br>
Cc:</b> 'lttng-dev@lists.lttng.org'<b><br>
Subject:</b> efficient use of LTTng in legacy codebase</font>
<br><font size=2 face="Calibri">Hello Mathieu,</font>
<br><font size=2 face="Calibri">Our team was asked to support LTTng UST
solution in a legacy codebase. The existing codebase is fairly large, and
the requirement is that we provide all the existing logs and debugs in
the system as LTTng traces.</font>
<br><font size=2 face="Calibri">The planned solution so far was just to
pass everything we have as text (strings) to LTTng. For that we obviously
have to convert the printf-like format string and parameter list to a string
by calling snprintf before giving the string to the LTTng API. That would
however mean, that these snprintfs are getting called every time even if
there is no listener/active trace session for the given trace. In this
case, all those unnecessary snprintf calls may end up significantly impacting
the performance of our applications.</font>
<br><font size=2 face="Calibri">In order to work around this, we were thinking
that if there was a way to query the LTTng library from our application
code whether there is an active tracing session for the given trace level,
we could avoid calling those snprintfs in case they are not needed. Do
you think it would be feasible to easily get this data from LTTng lib?
If yes, can you provide us some pointers where to look at in order to do
those changes ourselves?</font>
<br><font size=2 face="Calibri">Any suggestions are welcome.</font>
<br><font size=2 face="Calibri">Thank you,</font>
<br><font size=2 face="Calibri">Mate Ferenczy</font>
<br><font size=3> </font>
<br><font size=3> </font>
<br><font size=3>-- </font>
<br><font size=3>Mathieu Desnoyers<br>
EfficiOS Inc.</font><font size=3 color=blue><u><br>
</u></font><a href=http://www.efficios.com/ target=_blank><font size=3 color=blue><u>http://www.efficios.com</u></font></a>
<br><font size=3> </font>
<br><font size=3> </font>
<br><font size=3>-- </font>
<br><font size=3>Mathieu Desnoyers<br>
EfficiOS Inc.</font><font size=3 color=blue><u><br>
</u></font><a href=http://www.efficios.com/><font size=3 color=blue><u>http://www.efficios.com</u></font></a><tt><font size=2>_______________________________________________<br>
lttng-dev mailing list<br>
lttng-dev@lists.lttng.org<br>
</font></tt><a href="http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev"><tt><font size=2>http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev</font></tt></a><tt><font size=2><br>
</font></tt>
<br>