<div dir="ltr"><div>A few years ago, I was wondering the same, so I did some research and wrote a blog: </div><div><a href="https://www.javaadvent.com/2019/12/measuring-time-from-java-to-kernel-and-back.html">https://www.javaadvent.com/2019/12/measuring-time-from-java-to-kernel-and-back.html</a></div><div><br></div><div>tl;dr: you should be good. tsc is sync'ed across cores since Nehalem  </div></div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Wed, Jun 4, 2025 at 7:48 PM Pavel Rappo <<a href="mailto:pavel.rappo@gmail.com">pavel.rappo@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">I was reading a book that refers to this 2015 post claiming that<br>
nanoTime can be non-monotonic:<br>
<a href="https://steveloughran.blogspot.com/2015/09/time-on-multi-core-multi-socket-servers.html" rel="noreferrer" target="_blank">https://steveloughran.blogspot.com/2015/09/time-on-multi-core-multi-socket-servers.html</a><br>
<br>
In fact, I'm not sure what the claim actually is, as the author is a<br>
bit vague. It's unclear whether they say that they have actually<br>
observed it, or they just strongly suspect that it's possible.<br>
<br>
Has non-monotonicity ever been observed by hotspot developers? Can it<br>
be observed on a modern hardware + JVM?<br>
<br>
Thanks,<br>
-Pavel<br>
</blockquote></div><div><br clear="all"></div><br><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature">“Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.”<br>Antoine de Saint Exupéry</div>