<p>By the way, only thing I can think of as being a possible issue is the pause instruction killing (or reducing) out of order/pipelined execution of the rest of the loop body. But then I don't know if this is such an issue as the loop exit will probably have a branch misprediction anyway, killing whatever is in the pipeline.</p>
<p>At any rate, would be interesting to see an explanation.</p>
<p>Cheers</p>
<p>Sent from my phone</p>
<div class="gmail_quote">On Aug 29, 2012 8:23 AM, "Vitaly Davidovich" <<a href="mailto:vitalyd@gmail.com">vitalyd@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<p>I'm actually curious to know if Eric can explain a bit more why pause is an issue here, possibly with some benchmark results.</p>
<p>David's point earlier was that he doesn't think there's benefit to it in the way hotspot spins, but removing pause implies it can actually do harm rather than simply being unhelpful.</p>
<p>I'm also assuming this is not AMD specific but Intel as well?</p>
<p>Thanks</p>
<p>Sent from my phone</p>
<div class="gmail_quote">On Aug 29, 2012 8:04 AM, "Peter Levart" <<a href="mailto:peter.levart@marand.si" target="_blank">peter.levart@marand.si</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Here's an interesting explanation about the impact of pause instruction in spin-wait loops:<br>
<br>
<a href="http://software.intel.com/en-us/articles/long-duration-spin-wait-loops-on-hyper-threading-technology-enabled-intel-processors/" target="_blank">http://software.intel.com/en-us/articles/long-duration-spin-wait-loops-on-hyper-threading-technology-enabled-intel-processors/</a><br>
<br>
4 years later: It may be that newer CPUs are more clever now.<br>
<br>
Regards, Peter<br>
<br>
On Tuesday, August 28, 2012 11:36:23 AM Eric Caspole wrote:<br>
> Hi everybody,<br>
> I have made a webrev making a one-line change to remove use of PAUSE<br>
> in linux x64. This will bring linux into sync with windows where<br>
> SpinPause is just "return 0" as Dan indicates below.<br>
><br>
> <a href="http://cr.openjdk.java.net/~ecaspole/nopause/webrev.00/webrev/" target="_blank">http://cr.openjdk.java.net/~ecaspole/nopause/webrev.00/webrev/</a><br>
><br>
> We find that it is better not to use PAUSE in this kind of spin<br>
> routine. Apparently someone discovered that on windows x64 years ago.<br>
> Thanks,<br>
> Eric<br>
><br>
> On Aug 16, 2012, at 5:07 PM, Daniel D. Daugherty wrote:<br>
> > On Win64, SpinPause() has been "return 0" since mid-2005. Way back<br>
> ><br>
> > when Win64 code was in os_win32_amd64.cpp:<br>
> > SCCS/s.os_win32_amd64.cpp:<br>
> ><br>
> > D 1.9.1.1 05/07/04 03:20:45 dice 12 10 00025/00000/00334<br>
> > MRs:<br>
> > COMMENTS:<br>
> > 5030359 -- back-end synchonization improvements - adaptive<br>
> ><br>
> > spinning, etc<br>
> ><br>
> > When the i486 and amd64 cpu dirs were merged back in 2007, the code<br>
> ><br>
> > became like it is below (#ifdef'ed):<br>
> > D 1.32 07/09/17 09:11:33 sgoldman 37 35 00264/00008/00218<br>
> > MRs:<br>
> > COMMENTS:<br>
> > 5108146 Merge i486 and amd64 cpu directories.<br>
> > Macro-ized register names. Inserted amd64 specific code.<br>
> ><br>
> > Looks like on Linux-X64, the code has used the PAUSE instruction<br>
> ><br>
> > since mid-2005:<br>
> > D 1.3 05/07/04 03:14:09 dice 4 3 00031/00000/00353<br>
> > MRs:<br>
> > COMMENTS:<br>
> > 5030359 -- back-end synchonization improvements - adaptive<br>
> ><br>
> > spinning, etc<br>
> ><br>
> > We'll have to see if Dave Dice remember why he implemented<br>
> > it this way...<br>
> ><br>
> > Dan<br>
> ><br>
> > On 8/16/12 12:01 PM, Eric Caspole wrote:<br>
> >> Hi everybody,<br>
> >> Does anybody know the reason why SpinPause is simply "return 0" on<br>
> >> Win64 but uses PAUSE on Linux in a .s file?<br>
> >> We would like to remove PAUSE from linux too.<br>
> >><br>
> >> Thanks,<br>
> >> Eric<br>
> >><br>
> >><br>
> >> ./src/os_cpu/windows_x86/vm/os_windows_x86.cpp<br>
> >><br>
> >> 548 extern "C" int SpinPause () {<br>
> >> 549 #ifdef AMD64<br>
> >> 550 return 0 ;<br>
> >> 551 #else<br>
> >> 552 // pause == rep:nop<br>
> >> 553 // On systems that don't support pause a rep:nop<br>
> >> 554 // is executed as a nop. The rep: prefix is ignored.<br>
> >> 555 _asm {<br>
> >> 556 pause ;<br>
> >> 557 };<br>
> >> 558 return 1 ;<br>
> >> 559 #endif // AMD64<br>
> >> 560 }<br>
> >><br>
> >> src/os_cpu/linux_x86/vm/linux_x86_64.s<br>
> >><br>
> >> 63 .globl SpinPause<br>
> >> 64 .align 16<br>
> >> 65 .type SpinPause,@function<br>
> >> 66 SpinPause:<br>
> >> 67 rep<br>
> >> 68 nop<br>
> >> 69 movq $1, %rax<br>
> >> 70 ret<br>
</blockquote></div>
</blockquote></div>