<div dir="ltr">Each mesh could have its own mutex, which needs to be obtained by the thread which wants to write it. Or if a thread can do something else, use trylock and come back later to the mesh which was already locked.<div><br></div><div>Regards</div></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr">Dženan Zukić, PhD, Senior R&D Engineer,<span style="font-size:12.8000001907349px"> </span>Kitware (Carrboro, N.C.)</div></div></div></div></div></div></div></div></div></div></div></div></div>
<br><div class="gmail_quote">On Thu, Jun 22, 2017 at 3:45 PM, Milef, Nicholas Boris <span dir="ltr"><<a href="mailto:milefn@rpi.edu" target="_blank">milefn@rpi.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>
<div style="direction:ltr;font-family:Tahoma;color:#000000;font-size:10pt">Ok, after talking to Zhaohui and profiling, it appears to be a thread synchronization issue (which is why it only shows up in debug mode).
<div><br>
</div>
<div>This is the problem:</div>
<div>The render thread reads the mesh data. If the transform hasn't been applied, it gets applied.</div>
<div>The physics thread writes the mesh data. If the transform hasn't been applied, it gets applied.</div>
<div><br>
</div>
<div>The problem is that the render thread continually modifies the data as it's reading it. Meanwhile, the physics thread is setting data very quickly (or vice-versa, depending who wins the race condition). We saw earlier that the physics thread was less than
1 FPS, but now the render thread is less than 1 FPS. We don't synchronize between threads (which is another problem), so this is what's causing this.</div>
<div><br>
</div>
<div>Any ideas on how to proceed?</div>
<div>
<div style="font-family:Times New Roman;color:#000000;font-size:16px">
<hr>
<div id="m_-7647481330803936627divRpF722902" style="direction:ltr"><font face="Tahoma" size="2" color="#000000"><b>From:</b> Imstk-developers [<a href="mailto:imstk-developers-bounces@imstk.org" target="_blank">imstk-developers-bounces@<wbr>imstk.org</a>] on behalf of Dzenan Zukic [<a href="mailto:dzenan.zukic@kitware.com" target="_blank">dzenan.zukic@kitware.com</a>]<br>
<b>Sent:</b> Friday, June 09, 2017 11:53 AM<br>
<b>To:</b> Zhaohui Xia<div><div class="h5"><br>
<b>Cc:</b> <a href="mailto:imstk-developers@imstk.org" target="_blank">imstk-developers@imstk.org</a><br>
<b>Subject:</b> Re: [Imstk-developers] high-speed thread in iMSTK<br>
</div></div></font><br>
</div><div><div class="h5">
<div></div>
<div>
<div dir="ltr">Hi Zhaohui,
<div><br>
</div>
<div>something like <a href="https://stackoverflow.com/questions/41264827/setting-optimization-settings-in-visual-studio-through-cmake" target="_blank">
this</a> should work, you need to modify debug mode instead of release though.</div>
<div><br>
</div>
<div>Regards</div>
</div>
<div class="gmail_extra"><br clear="all">
<div>
<div class="m_-7647481330803936627gmail_signature">
<div dir="ltr">
<div>
<div dir="ltr">
<div>
<div dir="ltr">
<div>
<div dir="ltr">
<div>
<div dir="ltr">
<div>
<div dir="ltr">Dženan Zukić, PhD, Senior R&D Engineer,<span style="font-size:12.8000001907349px"> </span>Kitware (Carrboro, N.C.)</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<br>
<div class="gmail_quote">On Fri, Jun 9, 2017 at 11:50 AM, Zhaohui Xia <span dir="ltr">
<<a href="mailto:unihui@gmail.com" target="_blank">unihui@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div lang="EN-US">
<div class="m_-7647481330803936627m_4218457722802193441WordSection1">
<p class="MsoNormal"><span style="font-family:"Microsoft JhengHei Light",sans-serif;color:#1f497d">Hi Dzenan,<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-family:"Microsoft JhengHei Light",sans-serif;color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-family:"Microsoft JhengHei Light",sans-serif;color:#1f497d">Thanks for your advice. We need to set it for all the projects in the solution, is this correct?<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-family:"Microsoft JhengHei Light",sans-serif;color:#1f497d">Can we change it in the .CMakeList file to change the whole settings in an easy way?<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-family:"Microsoft JhengHei Light",sans-serif;color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-family:"Microsoft JhengHei Light",sans-serif;color:#1f497d">Thanks,<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-family:"Microsoft JhengHei Light",sans-serif;color:#1f497d">Zhaohui<u></u><u></u></span></p>
<p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">From:</span></b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"> Dzenan Zukic [mailto:<a href="mailto:dzenan.zukic@kitware.com" target="_blank">dzenan.zukic@kitware.c<wbr>om</a>]
<br>
<b>Sent:</b> 2017</span><span lang="ZH-CN" style="font-size:11.0pt">年</span><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">6</span><span lang="ZH-CN" style="font-size:11.0pt">月</span><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">9</span><span lang="ZH-CN" style="font-size:11.0pt">日</span><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">
8:57<br>
<b>To:</b> Zhaohui Xia <<a href="mailto:unihui@gmail.com" target="_blank">unihui@gmail.com</a>><br>
<b>Cc:</b> Andinet Enquobahrie <<a href="mailto:andinet.enqu@kitware.com" target="_blank">andinet.enqu@kitware.com</a>>;
<a href="mailto:imstk-developers@imstk.org" target="_blank">imstk-developers@imstk.org</a></span></p>
<div>
<div class="m_-7647481330803936627h5"><br>
<b>Subject:</b> Re: [Imstk-developers] high-speed thread in iMSTK<u></u><u></u></div>
</div>
<p></p>
<div>
<div class="m_-7647481330803936627h5">
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal">Hi Zhaohui,<u></u><u></u></p>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">to enable a somewhat higher speed of debug mode, you can manually change the compiler settings for individual projects, see
<a href="https://msdn.microsoft.com/en-us/library/8f8h5cxt.aspx" target="_blank">
this</a> and <a href="https://msdn.microsoft.com/en-us/library/k1ack8f1.aspx" target="_blank">
this</a>. Enabling optimizations increases difficulty of debugging, so you might enable more optimizations for the Visual Studio projects you are not trying to debug, and keep optimization disabled or at a low setting for the ones you are modifying.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">Regards<u></u><u></u></p>
</div>
</div>
<div>
<p class="MsoNormal"><br clear="all">
<u></u><u></u></p>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<p class="MsoNormal">Dženan Zukić, PhD, Senior R&D Engineer,<span style="font-size:9.5pt"> </span>Kitware (Carrboro, N.C.)<u></u><u></u></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal">On Thu, Jun 8, 2017 at 3:33 PM, Zhaohui Xia <<a href="mailto:unihui@gmail.com" target="_blank">unihui@gmail.com</a>> wrote:<u></u><u></u></p>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm">
<div>
<div>
<p class="MsoNormal"><span style="font-family:"Microsoft JhengHei Light",sans-serif;color:#1f497d">Hi Andinet,</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-family:"Microsoft JhengHei Light",sans-serif;color:#1f497d"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-family:"Microsoft JhengHei Light",sans-serif;color:#1f497d">I am afraid I made a mistake. The device thread is definitely a high-speed thread. I figure out the issue, because I forget to close something when I change
the code in that thread.</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-family:"Microsoft JhengHei Light",sans-serif;color:#1f497d"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-family:"Microsoft JhengHei Light",sans-serif;color:#1f497d">I think there is no performance bottlenecks currently in the main thread under
</span><span style="font-family:"Microsoft JhengHei Light",sans-serif;color:red">Release
</span><span style="font-family:"Microsoft JhengHei Light",sans-serif;color:#1f497d">mode (60-70HZ), since the mesh size (1000 vertices) is not very big now.</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-family:"Microsoft JhengHei Light",sans-serif;color:#1f497d">But under
</span><span style="font-family:"Microsoft JhengHei Light",sans-serif;color:red">Debug
</span><span style="font-family:"Microsoft JhengHei Light",sans-serif;color:#1f497d">mode, the speed is too slow, it is just
</span><span style="font-family:"Microsoft JhengHei Light",sans-serif;color:red">0.16HZ
</span><span style="font-family:"Microsoft JhengHei Light",sans-serif;color:#1f497d">for the same mesh. Do we have any ways to improve it, e.g. changing some settings? It would be very helpful for work if it can run faster.</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-family:"Microsoft JhengHei Light",sans-serif;color:#1f497d"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-family:"Microsoft JhengHei Light",sans-serif;color:#1f497d">Thanks,</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-family:"Microsoft JhengHei Light",sans-serif;color:#1f497d">Zhaohui</span><u></u><u></u></p>
<p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">From:</span></b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"> Andinet Enquobahrie [mailto:<a href="mailto:andinet.enqu@kitware.com" target="_blank">andinet.enqu@kitware.c<wbr>om</a>]
<br>
<b>Sent:</b> 2017</span><span lang="ZH-CN" style="font-size:11.0pt;font-family:等线">年</span><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">6</span><span lang="ZH-CN" style="font-size:11.0pt;font-family:等线">月</span><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">8</span><span lang="ZH-CN" style="font-size:11.0pt;font-family:等线">日</span><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">
13:29<br>
<b>To:</b> Zhaohui Xia <<a href="mailto:unihui@gmail.com" target="_blank">unihui@gmail.com</a>><br>
<b>Cc:</b> <a href="mailto:imstk-developers@imstk.org" target="_blank">imstk-developers@imstk.org</a><br>
<b>Subject:</b> Re: [Imstk-developers] high-speed thread in iMSTK</span><u></u><u></u></p>
<div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
<div>
<p class="MsoNormal">Zhaohui<u></u><u></u></p>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">Can you profile your code and let us know the key performance bottlenecks in iMSTK?<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">This is something Dr. Des is also interested. We will be exploring ways of accelerating some of the modules.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">thanks<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">Andinet<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
<div>
<p class="MsoNormal">On Thu, Jun 8, 2017 at 12:40 PM, Zhaohui Xia <<a href="mailto:unihui@gmail.com" target="_blank">unihui@gmail.com</a>> wrote:<u></u><u></u></p>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0cm;margin-bottom:5.0pt">
<div>
<div>
<p class="MsoNormal"><span style="font-family:"Microsoft YaHei UI",sans-serif">Hi All,</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-family:"Microsoft YaHei UI",sans-serif"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-family:"Microsoft YaHei UI",sans-serif">Do we have a high-speed thread (e.g. 1000HZ) in iMSTK? I tried different modules e.g VRPNDeviceServer (device) and SceneMange (main thread), but the maximum frame rates of them are
60-70HZ under Release mode.</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-family:"Microsoft YaHei UI",sans-serif">I also tried to set the Loopdelay to 0.001 or smaller (from my understand, its default value is 0 should have the fastest speed, but it also 60-70HZ).</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-family:"Microsoft YaHei UI",sans-serif"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-family:"Microsoft YaHei UI",sans-serif">Thanks,</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-family:"Microsoft YaHei UI",sans-serif">Zhaohui</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-family:"Verdana",sans-serif;color:#3b3838;background:white">------------------------------<wbr>------------------------------<wbr>------------------------------<wbr>-----------------</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-family:"Microsoft YaHei Light";background:white">Zhaohui Xia, Ph.D.</span><span style="font-family:"Microsoft YaHei Light""><br>
<span style="background:white">Postdoctoral Research Associate, Center for Modeling, Simulation and Imaging in Medicine (CeMSIM)</span><br>
<span style="background:white">Rensselaer Polytechnic Institute</span></span><u></u><u></u></p>
</div>
</div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><br>
______________________________<wbr>_________________<br>
Imstk-developers mailing list<br>
<a href="mailto:Imstk-developers@imstk.org" target="_blank">Imstk-developers@imstk.org</a><br>
<a href="http://public.kitware.com/mailman/listinfo/imstk-developers" target="_blank">http://public.kitware.com/mail<wbr>man/listinfo/imstk-developers</a><u></u><u></u></p>
</blockquote>
</div>
<p class="MsoNormal"><br>
<br clear="all">
<u></u><u></u></p>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<p class="MsoNormal">-- <u></u><u></u></p>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<p class="MsoNormal">Andinet Enquobahrie, Ph.D., MBA<br>
Director of Medical Computing<br>
Kitware, Inc.<br>
<br>
<a href="http://www.kitware.com" target="_blank">http://www.kitware.com</a><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><a href="tel:%28919%29%20969-6990%20x311" target="_blank"><span style="font-size:9.5pt;color:#1155cc">(919) 969-6990 x311</span></a><u></u><u></u></p>
</div>
<div>
<div>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0cm;margin-bottom:5.0pt">
<div>
<p class="MsoNormal"><span style="font-size:9.5pt"> </span><u></u><u></u></p>
</div>
</blockquote>
</div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><br>
______________________________<wbr>_________________<br>
Imstk-developers mailing list<br>
<a href="mailto:Imstk-developers@imstk.org" target="_blank">Imstk-developers@imstk.org</a><br>
<a href="http://public.kitware.com/mailman/listinfo/imstk-developers" target="_blank">http://public.kitware.com/mail<wbr>man/listinfo/imstk-developers</a><u></u><u></u></p>
</blockquote>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</div>
</div></div></div>
</div>
</div>
</div>
</blockquote></div><br></div>