[erlang-questions] why my test case of socket are always slower much than c++

Loïc Hoguin essen@REDACTED
Tue Jun 18 18:22:49 CEST 2013


On 06/18/2013 05:41 PM, Daniel Goertzen wrote:
> - On the receive side, {active, once} might be faster.  For most uses it
> is the best way to do socket receives in Erlang.

Not true.

Active mode and recv are equivalent in speed when you don't know how 
much data you want. It used to be that recv was faster than active but 
this got optimized in one of the R15 releases.

The reason it is generally the best way is that you usually want to 
receive other kinds of messages at the same time.

On the other hand, if you know how much data you need, then a recv(Size) 
will be better because it won't return until it gets it all. Receiving a 
8MB file in 8 calls is obviously better than receiving it in 8000 messages.

As for why the test case has these results, the answer is simple. The 
case is testing sequential throughput. Erlang is optimized for 
concurrent low latency. Not quite the same. Erlang can do throughput 
though, if you increase the recv size.

-- 
Loïc Hoguin
Erlang Cowboy
Nine Nines
http://ninenines.eu



More information about the erlang-questions mailing list