Forum: Building VoltDB Clients

Post: currentTimeMillis is not millisecond precise - incorrect performance measurements

currentTimeMillis is not millisecond precise - incorrect performance measurements
MichaelGG
Mar 28, 2011
It seems that System.currentTimeMillis() is used a fair amount in VoltDB code. This is not guaranteed to any precision, although many platforms seem to provide 1-millisecond resolution. On Windows Server, the precision seems to be 15 or 16ms. This causes a problem with the Voter client, here:
while (this_millisecond <= last_millisecond) {
this_millisecond = System.currentTimeMillis();
}
Instead of performing a sub-ms wait, it'll perform a multiple-ms busy wait. This makes the client perform much, much slower than it should.
The Java client itself, in Distributer.java, if I'm reading this correctly, also relies on currentTimeMillis to calculate latency. If so, then the precision reported will be a lot less than expected, on some platforms. Windows Server (tested on 2008 R2) seems to have this issue; Windows client (7) seems OK. System.nanoTime might be more suitable for these calculations.
Hi Michael, Thanks for
aweisberg
Mar 30, 2011
Hi Michael,
Thanks for testing this. It looks like we need a different strategy for sampling time on Windows. We use nanoTime sparingly on Linux because it is too slow. I created https://issues.voltdb.com/browse/ENG-1089 to track the issue.
Thanks,
Ariel