On 04/29/2017 04:56 PM, J Crawford wrote:
> The mystery boils down to: 
> 
>     "/The exact same block of code becomes slower after a busy spin pause./"
> 
> I posted a short source code that *unequivocally* proves and demonstrates the
> problem: 
> http://stackoverflow.com/questions/43696948/why-does-the-jvm-show-more-latency-for-the-same-block-of-code-after-a-busy-spin

I don't think this is much of the mystery, because wakeup from a long sleep
causes gradual transition from low power/frequency/scheduling states to higher
ones.

This is clearly visible if you do several consecutive operations after the
sleep, e.g. by adding this:

   while(count < results.length) {
+    if ((count & 7) > 0) interval = 0;
     double x = busyPause(interval);

Results:
191
191
191
191
191
193
190
190
194
192
192
191
191
191
191
4682   <--- wakeup
323    <--- (yaaaaaawn, still sleepy)
204    <--- (okay, let's have some morning coffee)
189    <--- (alright, we are at full swing)
191
192
195
189
2868   <--- WHAT. I HAVEN'T BEEN SLEEPING DEEPLY YET
273
222
191
194
189
192


Pretty sure configuring the system to avoid deep power states would alleviate
the first several iterations jump at the expense of power draw.

Thanks,
-Aleksey

-- 
You received this message because you are subscribed to the Google Groups 
"mechanical-sympathy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mechanical-sympathy+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to