[erlang-questions] gen_tcp/ssl send function and large binaries, should I split?

Lukas Larsson garazdawi@REDACTED
Thu Jan 2 12:04:44 CET 2014


Hello,

As always with these things you should measure your specific scenario and
see if it is worth it for you.

Purely theritically[1] I would imagine that the above loop would add a
little bit of overhead, mainly from the fact that the total number of
function calls goes up. The C code in the inet_driver should be largely
unaffected by this as it would only append the data to its own queue. I
would be surprised if you could measure any difference in throughput.

So I would recommend using the simpler `Transport:send(Socket, Data)`
unless you actually can measure a difference.

Lukas

   [1]: for gen_tcp, I don't know much about how ssl does things, the
encryption parts could effect this.



On Mon, Dec 30, 2013 at 12:58 PM, Benoit Chesneau <bchesneau@REDACTED>wrote:

> Hi all,
>
> Actually when I send a large binary I split it chunk of 64MB and loop
> until the end:
>
>
>     send(<<Data:65536000/binary, Rest/binary >>, Transport, Socket) ->
>         Transport:send(Socket, Data);
>     send(Data, Transport, Socket) ->
>         Transport:send(Socket, Data).
>
>
> But I wonder if it's really useful, Does gen_tcp:semd and ssl:send take
> care about it? Should I just use `Transport:send(Socket, Data)` ?
>
>
> - benoit
>
>
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20140102/e0b125c6/attachment.htm>


More information about the erlang-questions mailing list