From 9e4895da833b7777e69efc173f5dc777aaea3201 Mon Sep 17 00:00:00 2001 From: Rickard Green Date: Thu, 29 Nov 2012 01:24:43 +0100 Subject: Add support for busy port message queue --- lib/kernel/doc/src/inet.xml | 64 +++++++++++++++++++++++++++++++++++++++++++++ lib/kernel/src/gen_tcp.erl | 4 +++ lib/kernel/src/inet.erl | 11 +++++--- lib/kernel/src/inet_int.hrl | 2 ++ 4 files changed, 77 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/kernel/doc/src/inet.xml b/lib/kernel/doc/src/inet.xml index bf6c4cfb1a..bfdb163e17 100644 --- a/lib/kernel/doc/src/inet.xml +++ b/lib/kernel/doc/src/inet.xml @@ -487,6 +487,36 @@ fe80::204:acff:fe17:bf38 example Size == 2, the data received will match [Byte1,Byte2|Binary].

+ {high_msgq_watermark, Size} (TCP/IP sockets) + +

The socket message queue will be set into a busy + state when the amount of data queued on the message + queue reaches this limit. Note that this limit only + concerns data that have not yet reached the ERTS internal + socket implementation. Default value used is 8 kB.

+

Senders of data to the socket will be suspended if + either the socket message queue is busy, or the socket + itself is busy.

+

For more information see the low_msgq_watermark, + high_watermark, and low_watermark options.

+

Note that distribution sockets will disable the use of + high_msgq_watermark and low_msgq_watermark, + and will instead use the + distribution + buffer busy limit which is a similar feature.

+
+ {high_watermark, Size} (TCP/IP sockets) + +

The socket will be set into a busy state when the amount + of data queued internally by the ERTS socket implementation + reaches this limit. Default value used is 8 kB.

+

Senders of data to the socket will be suspended if + either the socket message queue is busy, or the socket + itself is busy.

+

For more information see the low_watermark, + high_msgq_watermark, and low_msqg_watermark + options.

+
{keepalive, Boolean}(TCP/IP sockets)

Enables/disables periodic transmission on a connected @@ -495,6 +525,40 @@ fe80::204:acff:fe17:bf38 considered broken and an error message will be sent to the controlling process. Default disabled.

+ {low_msgq_watermark, Size} (TCP/IP sockets) + +

If the socket message queue is in a busy state, the + socket message queue will be set in a not busy state when + the amount of data queued in the message queue falls + below this limit. Note that this limit only concerns data + that have not yet reached the ERTS internal socket + implementation. Default value used is 4 kB.

+

Senders that have been suspended due to either a + busy message queue or a busy socket, will be resumed + when neither the socket message queue, nor the socket + are busy.

+

For more information see the high_msgq_watermark, + high_watermark, and low_watermark options.

+

Note that distribution sockets will disable the use of + high_msgq_watermark and low_msgq_watermark, + and will instead use the + distribution + buffer busy limit which is a similar feature.

+
+ {low_watermark, Size} (TCP/IP sockets) + +

If the socket is in a busy state, the socket will + be set in a not busy state when the amount of data + queued internally by the ERTS socket implementation + falls below this limit. Default value used is 4 kB.

+

Senders that have been suspended due to either a + busy message queue or a busy socket, will be resumed + when neither the socket message queue, nor the socket + are busy.

+

For more information see the high_watermark, + high_msgq_watermark, and low_msgq_watermark + options.

+
{nodelay, Boolean}(TCP/IP sockets)

If Boolean == true, the TCP_NODELAY option diff --git a/lib/kernel/src/gen_tcp.erl b/lib/kernel/src/gen_tcp.erl index ef6bfdf7f4..519c1bb8b4 100644 --- a/lib/kernel/src/gen_tcp.erl +++ b/lib/kernel/src/gen_tcp.erl @@ -38,9 +38,11 @@ {dontroute, boolean()} | {exit_on_close, boolean()} | {header, non_neg_integer()} | + {high_msgq_watermark, pos_integer()} | {high_watermark, non_neg_integer()} | {keepalive, boolean()} | {linger, {boolean(), non_neg_integer()}} | + {low_msgq_watermark, pos_integer()} | {low_watermark, non_neg_integer()} | {mode, list | binary} | list | binary | {nodelay, boolean()} | @@ -68,9 +70,11 @@ dontroute | exit_on_close | header | + high_msgq_watermark | high_watermark | keepalive | linger | + low_msgq_watermark | low_watermark | mode | nodelay | diff --git a/lib/kernel/src/inet.erl b/lib/kernel/src/inet.erl index abaf4486dc..e791bb135f 100644 --- a/lib/kernel/src/inet.erl +++ b/lib/kernel/src/inet.erl @@ -535,6 +535,7 @@ options() -> buffer, header, active, packet, deliver, mode, multicast_if, multicast_ttl, multicast_loop, exit_on_close, high_watermark, low_watermark, + high_msgq_watermark, low_msgq_watermark, bit8, send_timeout, send_timeout_close ]. @@ -552,8 +553,9 @@ stats() -> connect_options() -> [tos, priority, reuseaddr, keepalive, linger, sndbuf, recbuf, nodelay, header, active, packet, packet_size, buffer, mode, deliver, - exit_on_close, high_watermark, low_watermark, bit8, send_timeout, - send_timeout_close, delay_send,raw]. + exit_on_close, high_watermark, low_watermark, high_msgq_watermark, + low_msgq_watermark, bit8, send_timeout, send_timeout_close, + delay_send,raw]. connect_options(Opts, Family) -> BaseOpts = @@ -608,8 +610,9 @@ con_add(Name, Val, R, Opts, AllOpts) -> listen_options() -> [tos, priority, reuseaddr, keepalive, linger, sndbuf, recbuf, nodelay, header, active, packet, buffer, mode, deliver, backlog, - exit_on_close, high_watermark, low_watermark, bit8, send_timeout, - send_timeout_close, delay_send, packet_size,raw]. + exit_on_close, high_watermark, low_watermark, high_msgq_watermark, + low_msgq_watermark, bit8, send_timeout, send_timeout_close, + delay_send, packet_size,raw]. listen_options(Opts, Family) -> BaseOpts = diff --git a/lib/kernel/src/inet_int.hrl b/lib/kernel/src/inet_int.hrl index cf893c73eb..2dfbf75d25 100644 --- a/lib/kernel/src/inet_int.hrl +++ b/lib/kernel/src/inet_int.hrl @@ -141,6 +141,8 @@ -define(INET_LOPT_READ_PACKETS, 33). -define(INET_OPT_RAW, 34). -define(INET_LOPT_TCP_SEND_TIMEOUT_CLOSE, 35). +-define(INET_LOPT_TCP_MSGQ_HIWTRMRK, 36). +-define(INET_LOPT_TCP_MSGQ_LOWTRMRK, 37). % Specific SCTP options: separate range: -define(SCTP_OPT_RTOINFO, 100). -define(SCTP_OPT_ASSOCINFO, 101). -- cgit v1.2.3