[erlang-questions] Sending message at a specific and accurate time

Jesper Louis Andersen jesper.louis.andersen@REDACTED
Sun Feb 21 20:32:03 CET 2016

On Sun, Feb 21, 2016 at 7:53 PM, Joe Armstrong <erlang@REDACTED> wrote:

> I'm getting about a 4 - 9 ms. inaccuracy in the time the messages is sent
> and
> the time I want it to be sent - but I'd like it to be much more accurate
> (sub ms if possible)

I would start by making measurements without the network component. When
you would send the gen_udp message, you take a timestamp, and analyze the
skew from the suggested skew. This lets you estimate the overhead of the
rest of the system in isolation from your own code and the Erlang VM.

Intuitively, 4 to 9 milliseconds is much higher than what I would expect.
But note that if you sleep for, say, 40ms, you will be awoken on the 41ms
flank at the earliest. This is because you are usually "inside" a
millisecond when you make the call so you start by taking the ceiling of
that milli-second before you.

How much other work is your Erlang VM doing when you make these
measurements? You are saying between 4 to 9 ms, which is variance
suggesting the VM has lots of work to do at that moment. And of course such
stuff will affect the running time. You can switch priority of your
processes up to high, but this comes at the expense of other calculations
if you can't finish your work quickly in the process with high priority.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20160221/0e63face/attachment.htm>

More information about the erlang-questions mailing list