Просмотр исходного кода

Increase the buffer size - this speeds up performance a lot in some cases.

https://github.com/epgsql/epgsql/pull/15
David N. Welton 11 лет назад
Родитель
Сommit
c344be601a
1 измененных файлов с 9 добавлено и 0 удалено
  1. 9 0
      src/pgsql_sock.erl

+ 9 - 0
src/pgsql_sock.erl

@@ -162,6 +162,15 @@ command({connect, Host, Username, Password, Opts}, State) ->
     SockOpts = [{active, false}, {packet, raw}, binary, {nodelay, true}],
     {ok, Sock} = gen_tcp:connect(Host, Port, SockOpts, Timeout),
 
+    %% Increase the buffer size.  Following the recommendation in the inet man page:
+    %%
+    %%    It is recommended to have val(buffer) >=
+    %%    max(val(sndbuf),val(recbuf)).
+
+    {ok, [{recbuf, RecBufSize}, {sndbuf, SndBufSize}]} =
+        inet:getopts(Sock, [recbuf, sndbuf]),
+    inet:setopts(Sock, [{buffer, max(RecBufSize, SndBufSize)}]),
+
     State2 = case proplists:get_value(ssl, Opts) of
                  T when T == true; T == required ->
                      start_ssl(Sock, T, Opts, State);