One of the problems that I remember is that every core has its own counter, if 
you want to get reliable measurements you would need to pin the thread to a 
core between measurements (calls to RDTSC). At least that is what I remember 
from the top of my head. I guess that’s why it’s not an option for the JVM. 
Although, they could provide a Unsafe function ;)


From: 'Carl Mastrangelo' via mechanical-sympathy 
<[email protected]>
Reply-To: "[email protected]" 
<[email protected]>
Date: Monday, 29 April 2019 at 23:36
To: mechanical-sympathy <[email protected]>
Subject: Faster System.nanotime() ?

This may be a dumb question, but why (on Linux) is System.nanotime() a call out 
to clock_gettime?    It seems like it could be inlined by the JVM, and stripped 
down to the rdtsc instruction.   From my reading of the vDSO source for x86, 
the implementation is not that complex, and could be copied into Java.
--
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]<mailto:[email protected]>.
For more options, visit https://groups.google.com/d/optout.

-- 
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.

Reply via email to