[erlang-questions] What does "soft" real-time mean?

Hugo Mills hugo@REDACTED
Fri Oct 20 15:47:38 CEST 2017


On Fri, Oct 20, 2017 at 05:30:47PM +0530, Avinash Dhumane wrote:
> I have programmed high-frequency trading application in Erlang and
> comparing its reaction performance in the live market with other competing
> applications (mostly, in C).
> 
> It has been a consistent observation that my Erlang application lags
> substantially behind the competing applications. In fact, it never matched
> the reaction time of the so-called "slowest" C application in the market.
> 
> The benchmark reaction time is about 5 microseconds. It is the time elapsed
> between tick to order. That is, the difference between the timestamps when
> I receive the tick (market event) from the mailbox of my process and when I
> submit the TCP send call on my order.

   You're combining two measures here:

 - How fast does the process react once the message arrives in its
   mailbox? Not the time to getting a response out, but the delay
   between the message getting to the process, and the process being
   scheduled to actually start work on processing it.

 - Once the process starts work on it, how fast can it get the result
   out?

   Erlang's reputation is that's it's very good at the former measure,
even when there are many thousands of processes competing to be
scheduled.

   On the second measure, that's more about the efficiency of
executing the code once it starts. Depending on what you're doing in
the process, it will almost certainly be slower to do the actual work
than equivalent code in C, possibly _much_ slower.

   Note, however, that sometimes you can end up writing very poor
(inefficient) Erlang by following an efficient C implementation too
closely, and that a different implementation which takes account of
the functional nature of Erlang will run much faster.

   So the first thing I'd look at here would be benchmarking the
service code first (standalone, in a tight loop, without the message
passing part), to see how fast that actually runs. That should then at
least give you a good idea of which of the two measures above is the
slow one.

   Hugo.

> My process maintains the market depths of the securities and when my
> desired price (as a function of best buyers and/or sellers on multiple legs
> of the order) is observed, I compute the order terms and submit.
> 
> The entire computation and communication (with the market) takes place
> within the single process and there are no collaborating processes (hence,
> no inter-process messaging; not even ETS). Still, the reaction time is in
> the order of 20 to 60 microseconds - that is, nowhere closer to the
> benchmark reaction time (5 microseconds).
> 
> What I wish to hear from the experienced people on this forum here is
> whether I am missing on something in my Erlang code, or should I just go
> ahead and program in C.
> 
> Thanks.

> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions


-- 
Hugo Mills             | Great films about cricket: The Fantastic Four
hugo@REDACTED carfax.org.uk |
http://carfax.org.uk/  |
PGP: E2AB1DE4          |
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20171020/98183674/attachment.bin>


More information about the erlang-questions mailing list