<div dir="ltr">Just pushed a topic that I hope fixes the issue properly:<div><br></div><div><a href="http://review.source.kitware.com/#/t/3176">http://review.source.kitware.com/#/t/3176</a></div><div><br></div><div style>I carefully looked into the <span style="font-family:arial,sans-serif;font-size:13px">Schwarz Counter idiom and decided to uses a modification of it. The issue here is that vtkTimeStamp.h is included by every subclass of vtkObject - thousands of .cxx files. This would have cause the creation of lots of static objects; initializer as it is called in</span></div>
<div style><span style="font-family:arial,sans-serif;font-size:13px"><br></span></div><div style><font face="arial, sans-serif">initializer</font><br></div><div style><font face="arial, sans-serif"><br></font></div><div style>
<font face="arial, sans-serif">which lots of unnecessary allocation, counter incrementing, decrementing etc. Please review the topic and comment. Or e-mail comments.</font></div><div style><font face="arial, sans-serif"><br>
</font></div><div style><font face="arial, sans-serif">Bill: if you get this before you are done, can you give it a try?</font></div><div style><font face="arial, sans-serif"><br></font></div><div style><font face="arial, sans-serif">-berk</font></div>
<div><br><div><br></div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Aug 26, 2013 at 3:02 PM, Berk Geveci <span dir="ltr"><<a href="mailto:berk.geveci@kitware.com" target="_blank">berk.geveci@kitware.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">A few lines above that comment says:<div><br></div><div><div> // Note that this would not normally be thread safe. However,</div>
<div> // VTK initializes static objects at load time, which in turn call</div>
<div> // this functions, which make this thread safe. If this behavior</div><div> // changes, this should also be fixed by converting it to a static</div><div> // class member which is initialized at load time.</div></div>
<div><br></div><div>That code gets called for the first time at library load time, which by definition would have to be done in a single thread. I would normally move it directly into library load time by using a static but then I run into initialization order issues. Actually, I realized that I can guarantee that it would get called at library load time. A fix coming shortly.</div>
<span class="HOEnZb"><font color="#888888">
<div><br></div><div>-berk</div><div><br></div></font></span></div><div class="gmail_extra"><br><br><div class="gmail_quote"><div class="im">On Mon, Aug 26, 2013 at 1:29 PM, Brad King <span dir="ltr"><<a href="mailto:brad.king@kitware.com" target="_blank">brad.king@kitware.com</a>></span> wrote:<br>
</div><div><div class="h5"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>On 08/26/2013 12:05 PM, Berk Geveci wrote:<br>
> Can you try this?<br>
<br>
</div>From the patch:<br>
<br>
+ if (!vtkTimeStamp::GlobalTimeStamp)<br>
+ {<br>
+#if VTK_SIZEOF_VOID_P == 8<br>
+ vtkTimeStamp::GlobalTimeStamp = new vtkAtomicInt64;<br>
<br>
This runtime initialization is not thread-safe, which IIUC<br>
is the entire point of using an atomic integer. We can<br>
achieve proper static initialization and finalization using<br>
the same Schwarz Counter idiom:<br>
<br>
<a href="http://en.wikibooks.org/wiki/More_C++_Idioms/Nifty_Counter" target="_blank">http://en.wikibooks.org/wiki/More_C++_Idioms/Nifty_Counter</a><br>
<br>
that we already use in several places. It provides a way<br>
to order things across translation units.<br>
<span><font color="#888888"><br>
-Brad<br>
</font></span></blockquote></div></div></div><br></div>
</blockquote></div><br></div>