<html><body><div style="font-family: times new roman, new york, times, serif; font-size: 12pt; color: #000000"><div>Just to speed things up, please have a look at the proposed UST patch. (it's not in mainline yet)<br></div><div><br></div><div>This is specifically for a demo program example so far.<br></div><div><br></div><div>Comments are welcome,<br></div><div><br></div><div>Thanks,<br></div><div><br></div><div>Mathieu<br></div><div><br></div><div><br></div><hr id="zwchr"><blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;"><b>From: </b>"Máté Ferenczy" <mate.ferenczy@ericsson.com><br><b>To: </b>"Mathieu Desnoyers" <mathieu.desnoyers@efficios.com><br><b>Cc: </b>lttng-dev@lists.lttng.org<br><b>Sent: </b>Wednesday, December 11, 2013 8:52:30 PM<br><b>Subject: </b>RE: efficient use of LTTng in legacy codebase<br><div><br></div>
<style><!--
@font-face
{font-family:Helvetica;
panose-1:2 11 5 4 2 2 2 2 2 4;}
@font-face
{font-family:Helvetica;
panose-1:2 11 5 4 2 2 2 2 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 2 4;}
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
{mso-style-priority:99;
mso-style-link:"Balloon Text Char";
margin:0in;
margin-bottom:.0001pt;
font-size:8.0pt;
font-family:"Tahoma","sans-serif";}
span.EmailStyle17
{mso-style-type:personal;
font-family:"Calibri","sans-serif";
color:windowtext;}
span.EmailStyle18
{mso-style-type:personal;
font-family:"Calibri","sans-serif";
color:#1F497D;}
span.EmailStyle19
{mso-style-type:personal-reply;
font-family:"Calibri","sans-serif";
color:#1F497D;}
span.BalloonTextChar
{mso-style-name:"Balloon Text Char";
mso-style-priority:99;
mso-style-link:"Balloon Text";
font-family:"Tahoma","sans-serif";}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style>
<div class="WordSection1">
<p class="MsoNormal"><span style="color:#1F497D">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?</span></p>
<p class="MsoNormal"><span style="color:#1F497D"> </span></p>
<p class="MsoNormal"><span style="color:#1F497D">For example:</span></p>
<p class="MsoNormal"><span style="font-family:"Courier New";color:#1F497D">#define ctf_format_string(_item, …) \</span></p>
<p class="MsoNormal"><span style="font-family:"Courier New";color:#1F497D"> do { \</span></p>
<p class="MsoNormal"><span style="font-family:"Courier New";color:#1F497D"> char _buf[BUF_MAXLEN]; \</span></p>
<p class="MsoNormal"><span style="font-family:"Courier New";color:#1F497D"> snprintf(buf, sizeof(_buf), __VA_ARGS__); \</span></p>
<p class="MsoNormal"><span style="font-family:"Courier New";color:#1F497D"> _ctf_string(_item, _buf, 0); \</span></p>
<p class="MsoNormal"><span style="font-family:"Courier New";color:#1F497D"> } while(0)</span></p>
<p class="MsoNormal"><span style="font-family:"Courier New";color:#1F497D">
</span></p>
<p class="MsoNormal"><span style="color:#1F497D">Or do you have some better place to put this logic?</span></p>
<p class="MsoNormal"><span style="color:#1F497D"> </span></p>
<p class="MsoNormal"><span style="color:#1F497D">Thanks,</span></p>
<p class="MsoNormal"><span style="color:#1F497D">Mate</span></p>
<p class="MsoNormal"><span style="color:#1F497D"> </span></p>
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> Mathieu Desnoyers [mailto:mathieu.desnoyers@efficios.com]
<br>
<b>Sent:</b> Wednesday, December 11, 2013 4:48 PM<br>
<b>To:</b> Máté Ferenczy<br>
<b>Cc:</b> lttng-dev@lists.lttng.org<br>
<b>Subject:</b> Re: efficient use of LTTng in legacy codebase</span></p>
</div>
</div>
<p class="MsoNormal"> </p>
<div>
<div class="MsoNormal" style="text-align:center" align="center"><span style="color:black">
<hr id="zwchr" align="center" size="3" width="100%">
</span></div>
<blockquote style="border:none;border-left:solid #1010FF 1.5pt;padding:0in 0in 0in 4.0pt;margin-left:3.75pt;margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><b><span style="font-family:"Helvetica","sans-serif";color:black">From:
</span></b><span style="font-family:"Helvetica","sans-serif";color:black">"Máté Ferenczy" <<a href="mailto:mate.ferenczy@ericsson.com" target="_blank">mate.ferenczy@ericsson.com</a>><br>
<b>To: </b>"mathieu desnoyers" <<a href="mailto:mathieu.desnoyers@efficios.com" target="_blank">mathieu.desnoyers@efficios.com</a>><br>
<b>Cc: </b><a href="mailto:lttng-dev@lists.lttng.org" target="_blank">lttng-dev@lists.lttng.org</a><br>
<b>Sent: </b>Wednesday, December 11, 2013 6:52:22 PM<br>
<b>Subject: </b>RE: efficient use of LTTng in legacy codebase</span></p>
<div>
<p class="MsoNormal"><span style="font-family:"Helvetica","sans-serif";color:black"> </span></p>
</div>
<p class="MsoNormal"><span style="color:black">I found this email thread: <a href="https://www.mail-archive.com/lttng-dev@lists.lttng.org/msg02278.html" target="_blank">
https://www.mail-archive.com/lttng-dev@lists.lttng.org/msg02278.html</a></span><br data-mce-bogus="1"></p>
<p class="MsoNormal"><span style="color:black">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?</span></p>
</blockquote>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman","serif";color:black"> </span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman","serif";color:black">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.</span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman","serif";color:black"> </span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman","serif";color:black">Thoughts ?</span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman","serif";color:black"> </span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman","serif";color:black">Thanks,</span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman","serif";color:black"> </span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman","serif";color:black">Mathieu</span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman","serif";color:black"> </span></p>
</div>
<blockquote style="border:none;border-left:solid #1010FF 1.5pt;padding:0in 0in 0in 4.0pt;margin-left:3.75pt;margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="color:black">Thanks,</span></p>
<p class="MsoNormal"><span style="color:black">Mate</span></p>
<p class="MsoNormal"><span style="color:#1F497D"> </span><span style="color:black"></span></p>
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif";color:black">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif";color:black"> Máté Ferenczy
<br>
<b>Sent:</b> Wednesday, December 11, 2013 12:17 PM<br>
<b>To:</b> 'mathieu.desnoyers@efficios.com'<br>
<b>Cc:</b> 'lttng-dev@lists.lttng.org'<br>
<b>Subject:</b> efficient use of LTTng in legacy codebase</span><span style="color:black"></span></p>
</div>
</div>
<p class="MsoNormal"><span style="color:black">Hello Mathieu,</span></p>
<p class="MsoNormal"><span style="color:black">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.</span></p>
<p class="MsoNormal"><span style="color:black">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.</span></p>
<p class="MsoNormal"><span style="color:black">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?</span></p>
<p class="MsoNormal"><span style="color:black">Any suggestions are welcome.</span></p>
<p class="MsoNormal"><span style="color:black">Thank you,</span></p>
<p class="MsoNormal"><span style="color:black">Mate Ferenczy</span></p>
</blockquote>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><span style="font-size:12.0pt;font-family:"Times New Roman","serif";color:black"> </span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman","serif";color:black"> </span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman","serif";color:black">--
</span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman","serif";color:black">Mathieu Desnoyers<br>
EfficiOS Inc.<br>
<a href="http://www.efficios.com" target="_blank">http://www.efficios.com</a></span><br data-mce-bogus="1"></p>
</div>
</div>
</div>
</blockquote><div><br><br></div><div><br></div><div>-- <br></div><div><span name="x"></span>Mathieu Desnoyers<br>EfficiOS Inc.<br>http://www.efficios.com<span name="x"></span><br></div></div></body></html>