News for hackers. Stuff that matters.
Re:The slow currentTimeMillis() by the8472 on Friday August 04, 2017 @07:59AM (#14928003)
Related and required reading if you're doing microbenchmarking: https://shipilev.net/blog/2014/nanotrusting-nanotime/

Also the, tsc CPU flag is not sufficient since early tsc implementations had issues that made them unusuable for walltime measurements. There's also constant_tsc and nonstop_tsc which are relevant because they indicate that tsc keeps ticking independent of frequency scaling and CPU low power modes, only then do they become usable for low-overhead userspace timekeeping.

hotspot and the linux vDSO generally take care of doing the right thing, depending on CPU flags, so the TSC is used for currentTimeMillis and nanoTime if it can determine that it is reliable, otherwise more expensive but accurate methods are used.

The article's own conclusion:

> The title isn’t completely correct: currentTimeMillis() isn’t always slow. However, there is a case when it is.

It only happens under circumstances where the TSCs are not used.

Re:The slow currentTimeMillis() by joosters on Friday August 04, 2017 @08:38AM (#14928211)
These points are all made in the original article...
Re:The slow currentTimeMillis() by the8472 on Friday August 04, 2017 @08:55AM (#14928305)
My point is that the heading is misleading. On modern systems linux/hotspot generally do the right thing(tm) and no tinkering with sysfs should be needed, if the right cpuflags (check /proc/cpuflags) are available. Some virtualization solutions may cause issues here.