On 04/29/2017 06:56 PM, Aleksey Shipilev wrote:
> 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);

Ah, I misread the test. busyPause is not powering down anything. What's weirder,
the first pair of nanoTime calls after exiting busyPause is hiccuping even
without calculations in between:

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

    long latency = System.nanoTime();
    latency = System.nanoTime() - latency;

    results[count++] = latency;
    interval = (count / WARMUP * (PAUSE - 1)) + 1;
  }

...
34
34
35
32
35
2547
51
35
34
36
33
35
...

-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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to