RDTSCP and System.nanoTime

Jeremy Manson jeremymanson at google.com
Thu Aug 12 11:01:53 PDT 2010

Hi folks,

Motivation: the overhead of System.nanoTime and
System.currentTimeMillis on Linux is pretty awful if you are trying to
use them frequently.

The motivation for not replacing System.nanoTime with a RDTSC-based
approach was, as I understand it, based on two things:

1) The older timestamp counters were processor-cycle based, and shut
down when the system was in power-savings mode, and

2) It used to be impossible to compensate for TSC drift between processors.

The Nehalem architecture seems to have fixed these problems with
Invariant TSC (which runs at a constant rate regardless of power
state) and support for the IA32_TSC_AUX register (which tells you what
CPU you are using when you read the counter).  See section 16.11.1 and
16.11.2 of:


I don't see code that looks like this in os_linux.cpp, so I was
wondering if you guys had any plans to support it.



More information about the hotspot-runtime-dev mailing list