<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style>
<!--
@font-face
        {font-family:Wingdings}
@font-face
        {font-family:宋体}
@font-face
        {font-family:宋体}
@font-face
        {font-family:Calibri}
@font-face
        {font-family:Tahoma}
@font-face
        {font-family:"\@宋体"}
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        text-align:justify;
        text-justify:inter-ideograph;
        font-size:10.5pt;
        font-family:"Calibri","sans-serif"}
a:link, span.MsoHyperlink
        {color:blue;
        text-decoration:underline}
a:visited, span.MsoHyperlinkFollowed
        {color:purple;
        text-decoration:underline}
span.EmailStyle17
        {font-family:"Calibri","sans-serif";
        color:windowtext}
span.EmailStyle18
        {font-family:"Calibri","sans-serif";
        color:#1F497D}
.MsoChpDefault
        {font-size:10.0pt}
@page WordSection1
        {margin:72.0pt 90.0pt 72.0pt 90.0pt}
div.WordSection1
        {}
-->
</style>
</head>
<body lang="ZH-CN" link="blue" vlink="purple" style="">
<div class="WordSection1">
<p class="MsoNormal"><span lang="EN-US" style="color:#1F497D">Could anyone review this for me, please?</span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:#1F497D"> </span></p>
<div>
<p class="MsoNormal"><span lang="EN-US" style="color:#1F497D">Regards,</span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:#1F497D">Yunda</span></p>
</div>
<p class="MsoNormal"><span lang="EN-US" style="color:#1F497D"> </span></p>
<div style="border:none; border-left:solid blue 1.5pt; padding:0cm 0cm 0cm 4.0pt">
<div>
<div style="border:none; border-top:solid #B5C4DF 1.0pt; padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal" align="left" style="text-align:left"><b><span lang="EN-US" style="font-size:10.0pt; font-family:"Tahoma","sans-serif"">From:</span></b><span lang="EN-US" style="font-size:10.0pt; font-family:"Tahoma","sans-serif"">
</span><span style="font-size:10.0pt; font-family:宋体">云达</span><span lang="EN-US" style="font-size:10.0pt; font-family:"Tahoma","sans-serif"">(Yunda)
<br>
<b>Sent:</b> Friday, April 19, 2013 4:26 PM<br>
<b>To:</b> hotspot-runtime-dev@openjdk.java.net; serviceability-dev@openjdk.java.net<br>
<b>Subject:</b> [PATCH] EnableTracing: output from multiple threads may be mixed together</span></p>
</div>
</div>
<p class="MsoNormal" align="left" style="text-align:left"><span lang="EN-US"> </span></p>
<p class="MsoNormal"><span lang="EN-US">Hi all,</span></p>
<p class="MsoNormal"><span lang="EN-US"> </span></p>
<p class="MsoNormal"><span lang="EN-US">I found that the output from multiple threads may be mixed together when using EnableTracing. It happens many times in my test case like this:</span></p>
<p class="MsoNormal"><span lang="EN-US"> </span></p>
<p class="MsoNormal"><span lang="EN-US">Allocation outside TLAB: [Allocation in new TLAB: [Allocation in new TLAB: [Allocation in new TLAB: [Class = [C, Allocation in new TLAB: [Class = [I, Allocation in new TLAB: [Java Monitor Wait: [Class = java/lang/String,
Allocation Size = 24, Allocation Size = 24, Class = java/lang/String, Class = [I, Allocation in new TLAB: [Class = [C, Allocation in new TLAB: [Allocation Size = 192]</span></p>
<p class="MsoNormal"><span lang="EN-US">Class = com/sun/org/apache/xerces/internal/dom/DeferredElementNSImpl, Allocation Size = 24, Allocation Size = 24, TLAB Size = 23712280]</span></p>
<p class="MsoNormal"><span lang="EN-US">TLAB Size = 24607080]</span></p>
<p class="MsoNormal"><span lang="EN-US">Allocation Size = 24, Monitor Class = java/lang/ref/Reference$Lock, TLAB Size = 25054480]</span></p>
<p class="MsoNormal"><span lang="EN-US">TLAB Size = 25054480]</span></p>
<p class="MsoNormal"><span lang="EN-US">Allocation in new TLAB: [Class = [CTLAB Size = 24607080]</span></p>
<p class="MsoNormal"><span lang="EN-US">Allocation Size = 72, Class = [C, TLAB Size = 24159728]</span></p>
<p class="MsoNormal"><span lang="EN-US">, Allocation Size = 32, TLAB Size = 23712288]</span></p>
<p class="MsoNormal"><span lang="EN-US"> </span></p>
<p class="MsoNormal"><span lang="EN-US">It's very confusing and it's even not easy to tell how many events there are. I think the reason is that the writeEvent() method of each Event* class output the fields of event one by one without using any lock. So I
made a small patch which add ttyLocker to writeEvent() method and after applying this patch there's no output mixed together in my test case(against
<a href="http://hg.openjdk.java.net/hsx/hsx24/hotspot/">http://hg.openjdk.java.net/hsx/hsx24/hotspot/</a>):</span></p>
<p class="MsoNormal"><span lang="EN-US">diff -r edd1619a3ae4 src/share/vm/trace/traceEventClasses.xsl</span></p>
<p class="MsoNormal"><span lang="EN-US">--- a/src/share/vm/trace/traceEventClasses.xsl Thu Apr 18 13:50:58 2013 -0700</span></p>
<p class="MsoNormal"><span lang="EN-US">+++ b/src/share/vm/trace/traceEventClasses.xsl Fri Apr 19 16:12:38 2013 +0800</span></p>
<p class="MsoNormal"><span lang="EN-US">@@ -132,6 +132,7 @@</span></p>
<p class="MsoNormal"><span lang="EN-US"> void writeEvent(void) {</span></p>
<p class="MsoNormal"><span lang="EN-US"> ResourceMark rm;</span></p>
<p class="MsoNormal"><span lang="EN-US"> HandleMark hm;</span></p>
<p class="MsoNormal"><span lang="EN-US">+ ttyLocker ttyl;</span></p>
<p class="MsoNormal"><span lang="EN-US"> TraceStream ts(*tty);</span></p>
<p class="MsoNormal"><span lang="EN-US"> ts.print("<xsl:value-of select="@label"/>: [");</span></p>
<p class="MsoNormal"><span lang="EN-US"><xsl:apply-templates select="value|structvalue" mode="write-data"/></span></p>
<p class="MsoNormal"><span lang="EN-US"> </span></p>
<p class="MsoNormal"><span lang="EN-US"> </span></p>
<p class="MsoNormal"><span lang="EN-US">I searched before sending this mail I didn't find anyone who covering this</span><span lang="EN-US" style="font-family:Wingdings">J</span><span lang="EN-US"></span></p>
<p class="MsoNormal"><span lang="EN-US"> </span></p>
<p class="MsoNormal"><span lang="EN-US">Regards,</span></p>
<p class="MsoNormal"><span lang="EN-US">Yunda</span></p>
<p class="MsoNormal"><span lang="EN-US"> </span></p>
</div>
</div>
<br>
<hr>
<font face="Arial" color="Gray" size="1"><br>
This email (including any attachments) is confidential and may be legally privileged. If you received this email in error, please delete it immediately and do not copy it or use it for any purpose or disclose its contents to any other person. Thank you.<br>
<br>
本电邮(包括任何附件)可能含有机密资料并受法律保护。如您不是正确的收件人,请您立即删除本邮件。请不要将本电邮进行复制并用作任何其他用途、或透露本邮件之内容。谢谢。<br>
</font>
</body>
</html>