I was curious too, seems it’s an operating system limit, See this other elixir forum thread, which links to this mailing list post, also this erlang forums post
Note this is from 2007, but the same restriction probably applies now:
Yes, it’s nothing Erlang-specific - pretty fundamental actually:
Timeouts can only happen on a system clock interrupt, and they obviously
happen with the frequency of your system clock, which is traditionally
100 Hz on Unix. You can crank it up on most Unixen if you care about
this - I believe some Linux kernel versions used 1000 Hz by default, but
they tended to lose clock interrupts then…
What OS are you running these tests on? Am I correct in guessing that it is Windows? When I run your test on Linux/macOS it returns
{2,1}
, but on Windows it is{16,18}
. This is because the interrupt interval on Windows is by default 1000ms / 64 (that is 16ms), so that is the best you are going to get there unless you change that interval.
Also Armstrong, on the mailing list
Erlang was designed for programming telephone exchanges - we wanted
response times of milliseconds for simple requests. We also didn’t want
long lived computations to block computations that could be performed
immediately - so each process gets an equal time slice of the CPU.
Which might be indicative that ms-accuracy was good enough for the initial application and so far has been good enough for most other applications too.
I could imagine wanting sub-ms precision for some, particular, C&C industrial controllers but I dont think those have been historically written in Erlang, so I would guess there isn’t much demand.