News for hackers. Stuff that matters.
Re:Nanosecond timestamp collisions are common by techNoob123 on Friday July 21, 2023 @03:43AM (#36811107)
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…

Re:Nanosecond timestamp collisions are common by rwmj on Friday July 21, 2023 @03:48AM (#36811155)
Linux will (x86_64) use RDTSC and adjust that against a value read from the VDSO, so it can indeed happen very quickly.
Re:Nanosecond timestamp collisions are common by dan-robertson on Friday July 21, 2023 @07:10PM (#36821248)
It 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’.