[PATCH] EnableTracing: output from multiple threads may be mixed together

云达(Yunda) yunda.mly at taobao.com
Fri Apr 19 01:26:14 PDT 2013


Hi all,

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:

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]
Class = com/sun/org/apache/xerces/internal/dom/DeferredElementNSImpl, Allocation Size = 24, Allocation Size = 24, TLAB Size = 23712280]
TLAB Size = 24607080]
Allocation Size = 24, Monitor Class = java/lang/ref/Reference$Lock, TLAB Size = 25054480]
TLAB Size = 25054480]
Allocation in new TLAB: [Class = [CTLAB Size = 24607080]
Allocation Size = 72, Class = [C, TLAB Size = 24159728]
, Allocation Size = 32, TLAB Size = 23712288]

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 http://hg.openjdk.java.net/hsx/hsx24/hotspot/):
diff -r edd1619a3ae4 src/share/vm/trace/traceEventClasses.xsl
--- a/src/share/vm/trace/traceEventClasses.xsl    Thu Apr 18 13:50:58 2013 -0700
+++ b/src/share/vm/trace/traceEventClasses.xsl Fri Apr 19 16:12:38 2013 +0800
@@ -132,6 +132,7 @@
   void writeEvent(void) {
     ResourceMark rm;
     HandleMark hm;
+    ttyLocker ttyl;
     TraceStream ts(*tty);
     ts.print("<xsl:value-of select="@label"/>: [");
<xsl:apply-templates select="value|structvalue" mode="write-data"/>


I searched before sending this mail I didn't find anyone who covering this☺

Regards,
Yunda


________________________________

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.

本电邮(包括任何附件)可能含有机密资料并受法律保护。如您不是正确的收件人,请您立即删除本邮件。请不要将本电邮进行复制并用作任何其他用途、或透露本邮件之内容。谢谢。
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/hotspot-runtime-dev/attachments/20130419/11098eb6/attachment.html 


More information about the hotspot-runtime-dev mailing list