News for hackers. Stuff that matters.
Re:The slow currentTimeMillis() by revelation on Friday August 04, 2017 @09:27AM (#14928474)
Why would there be a system performance impact? This is just updating a memory value (that happens to be mapped into the VM of every process) at 2 kHz.
Re:The slow currentTimeMillis() by dingo_bat on Friday August 04, 2017 @09:48AM (#14928597)
Silly me, the time is only updated once every half a millisecond. That's virtually zero CPU usage on a 2GHz chip.
Re:The slow currentTimeMillis() by amluto on Friday August 04, 2017 @10:42AM (#14928993)
It's worse than you might think. There are at least three things happening 2000x/second: getting an interrupt, writing shared memory, and returning. Getting a CPU interrupt takes something like 1k cycles. Dealing with the APIC may be even worse on a system without X2APIC, which is all too common due to crappy firmware (never benchmarked it, though), and returning takes many hundreds of cycles because x86 is very bad at these things. That shared memory write is n basically free unless NUMA is involved, and then it can be fairly bad.

So we're taking maybe 4M cycles per second used here. In practice, there's probably quite a bit of extra software overhead.