3 ms·
At some point doesn’t this come down to the ISA? A CPU running at 3GHz gets 3 clock cycles per nanosecond. I bet there is a fair amount of optimization in the
by techNoob123 3y ago
At some point doesn’t this come down to the ISA? A CPU running at 3GHz gets 3 clock cycles per nanosecond.
I bet there is a fair amount of optimization in the compiler that leads to back to back assembly calls of reading the clock register. If subsequent time.Now() calls happen within 3 clock cycles of each other, can you really fairly expect unique nanosecond precision…
- rwmj 3y agoLinux will (x86_64) use RDTSC and adjust that against a value read from the VDSO, so it can indeed happen very quickly.
- dan-robertson 3y agoIt takes like 20 cycles to read the cycle count register on modern chips. Even if collisions are somewhat unlikely, it’s still much worse to get several a day than ‘almost never going to happen’.