From 8faf1746ece60fc5fa634e5fd16e98df1ef7f3ba Mon Sep 17 00:00:00 2001 From: Scott Lystig Fritchie Date: Fri, 22 Oct 2010 15:25:10 -0500 Subject: Add flag-based setting for the distribution buffer busy limit Id: OTP-8912 This patch creates a new family of flags with the "+z" prefix. It further creates a new configuration option called "dbbl" (which is the first letter of the name dist_buf_busy_limit). Example usage of this flag would be "+zdbbl 1048576". This patch creates an adjustable buffer limit for the amount of data that may be buffered by the erlang distribution code (in dist.c specifically). Before this patch, this hard-coded constant was used: #define ERTS_DE_BUSY_LIMIT (128*1024) When large binaries are transmitted between nodes (or simply a lot of medium-sized binaries), it is very easy to hit the old 128KB limit. Processes that use the erlang:system_monitor() BIF to monitor system events can be spammed by {monitor, busy_dist_port, ...} message tuples at rates of tens to even hundreds of messages/second. A larger buffer limit will allow processes to buffer more outgoing messages over the distribution. When the buffer limit has been reached, sending processes will be suspended until the buffer size has shrunk. The buffer limit is per distribution channel. A higher limit will give lower latency and higher throughput at the expense of higher memory usage. A variation of this patch has been in commercial production use in at least two companies that the author is aware of. Larger buffer values can reduce the number of {monitor, busy_dist_port, ...} system messages drastically, lower overall messaging latencies, and prevent false timeouts and 'nodedown' messages in extremely busy Mnesia systems. Test suite: there are two tests: a. In erlexec_SUITE.erl to test basic set & get of the value b. In distribution_SUITE.erl, to verify that setting +zdbbl very low will actually change behavior. --- erts/etc/common/erlexec.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'erts/etc/common') diff --git a/erts/etc/common/erlexec.c b/erts/etc/common/erlexec.c index c1fc2aebee..d65a55f223 100644 --- a/erts/etc/common/erlexec.c +++ b/erts/etc/common/erlexec.c @@ -138,6 +138,12 @@ static char *plusr_val_switches[] = { NULL }; +/* +z arguments with values */ +static char *plusz_val_switches[] = { + "dbbl", + NULL +}; + /* * Define sleep(seconds) in terms of Sleep() on Windows. @@ -909,6 +915,20 @@ int main(int argc, char **argv) i++; } break; + case 'z': + if (!is_one_of_strings(&argv[i][2], plusz_val_switches)) { + goto the_default; + } else { + if (i+1 >= argc + || argv[i+1][0] == '-' + || argv[i+1][0] == '+') + usage(argv[i]); + argv[i][0] = '-'; + add_Eargs(argv[i]); + add_Eargs(argv[i+1]); + i++; + } + break; default: the_default: argv[i][0] = '-'; /* Change +option to -option. */ @@ -1096,7 +1116,7 @@ usage_aux(void) "[+l] [+M ] [+P MAX_PROCS] [+R COMPAT_REL] " "[+r] [+rg READER_GROUPS_LIMIT] [+s SCHEDULER_OPTION] " "[+S NO_SCHEDULERS:NO_SCHEDULERS_ONLINE] [+T LEVEL] [+V] [+v] " - "[+W] [args ...]\n"); + "[+W] [+z MISC_OPTION] [args ...]\n"); exit(1); } -- cgit v1.2.3