From 9d4912208e91c1cb3195bf86966a84e88e7c9ff9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Wed, 5 Feb 2025 16:22:06 +0100 Subject: [PATCH] Lower the lower dynamic buffer value to 1024 There's not a big performance difference between 8192 and 1024 so let's use less memory at the start of the connection. --- doc/src/manual/cowboy_http.asciidoc | 2 +- doc/src/manual/cowboy_http2.asciidoc | 2 +- doc/src/manual/cowboy_websocket.asciidoc | 2 +- src/cowboy.erl | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/src/manual/cowboy_http.asciidoc b/doc/src/manual/cowboy_http.asciidoc index 31e2d37c..ccddc550 100644 --- a/doc/src/manual/cowboy_http.asciidoc +++ b/doc/src/manual/cowboy_http.asciidoc @@ -76,7 +76,7 @@ connection_type (supervisor):: Whether the connection process also acts as a supervisor. -dynamic_buffer ({8192, 131072}):: +dynamic_buffer ({1024, 131072}):: Cowboy will dynamically change the socket's `buffer` size depending on the size of the data it receives from the socket. diff --git a/doc/src/manual/cowboy_http2.asciidoc b/doc/src/manual/cowboy_http2.asciidoc index a5fcd0b1..be485029 100644 --- a/doc/src/manual/cowboy_http2.asciidoc +++ b/doc/src/manual/cowboy_http2.asciidoc @@ -92,7 +92,7 @@ The connection window will only get updated when its size becomes lower than this threshold, in bytes. This is to avoid sending too many `WINDOW_UPDATE` frames. -dynamic_buffer ({8192, 131072}):: +dynamic_buffer ({1024, 131072}):: Cowboy will dynamically change the socket's `buffer` size depending on the size of the data it receives from the socket. diff --git a/doc/src/manual/cowboy_websocket.asciidoc b/doc/src/manual/cowboy_websocket.asciidoc index d5db82f2..319dbae3 100644 --- a/doc/src/manual/cowboy_websocket.asciidoc +++ b/doc/src/manual/cowboy_websocket.asciidoc @@ -249,7 +249,7 @@ options and the zlib compression options. The defaults optimize the compression at the expense of some memory and CPU. -dynamic_buffer ({8192, 131072}):: +dynamic_buffer ({1024, 131072}):: Cowboy will dynamically change the socket's `buffer` size depending on the size of the data it receives from the socket. diff --git a/src/cowboy.erl b/src/cowboy.erl index c6856498..dbe4d348 100644 --- a/src/cowboy.erl +++ b/src/cowboy.erl @@ -166,7 +166,7 @@ ensure_dynamic_buffer(TransOpts, #{dynamic_buffer := DynamicBuffer}) -> ensure_dynamic_buffer(TransOpts=#{socket_opts := SocketOpts}, _) -> case proplists:get_value(buffer, SocketOpts, undefined) of undefined -> - {TransOpts#{socket_opts => [{buffer, 8192}|SocketOpts]}, {8192, 131072}}; + {TransOpts#{socket_opts => [{buffer, 1024}|SocketOpts]}, {1024, 131072}}; _ -> {TransOpts, false} end.