From afc459f8fcda9d8d2f34d3818327e7d0f2387045 Mon Sep 17 00:00:00 2001 From: Charles-Henri Bruyand Date: Fri, 22 Sep 2023 15:37:26 +0200 Subject: [PATCH] doq: properly configure maxInFlight and max buffered data --- pdns/dnsdist-lua.cc | 4 +++- pdns/dnsdistdist/docs/reference/config.rst | 1 + pdns/dnsdistdist/doq.cc | 18 ++++++++++++++---- pdns/dnsdistdist/doq.hh | 1 + 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/pdns/dnsdist-lua.cc b/pdns/dnsdist-lua.cc index eccb9a9363..c3aa3c52f9 100644 --- a/pdns/dnsdist-lua.cc +++ b/pdns/dnsdist-lua.cc @@ -2510,7 +2510,9 @@ static void setupLuaConfig(LuaContext& luaCtx, bool client, bool configCheck) if (vars) { parseLocalBindVars(vars, reusePort, tcpFastOpenQueueSize, interface, cpus, tcpListenQueueSize, maxInFlightQueriesPerConn, tcpMaxConcurrentConnections); - + if (maxInFlightQueriesPerConn > 0) { + frontend->d_maxInFlight = maxInFlightQueriesPerConn; + } getOptionalValue(vars, "internalPipeBufferSize", frontend->d_internalPipeBufferSize); getOptionalValue(vars, "idleTimeout", frontend->d_idleTimeout); diff --git a/pdns/dnsdistdist/docs/reference/config.rst b/pdns/dnsdistdist/docs/reference/config.rst index c0a3287f41..f6ad305783 100644 --- a/pdns/dnsdistdist/docs/reference/config.rst +++ b/pdns/dnsdistdist/docs/reference/config.rst @@ -190,6 +190,7 @@ Listen Sockets * ``cpus={}``: table - Set the CPU affinity for this listener thread, asking the scheduler to run it on a single CPU id, or a set of CPU ids. This parameter is only available if the OS provides the pthread_setaffinity_np() function. * ``idleTimeout=5``: int - Set the idle timeout, in seconds. * ``internalPipeBufferSize=0``: int - Set the size in bytes of the internal buffer of the pipes used internally to pass queries and responses between threads. Requires support for ``F_SETPIPE_SZ`` which is present in Linux since 2.6.35. The actual size might be rounded up to a multiple of a page size. 0 means that the OS default size is used. The default value is 0, except on Linux where it is 1048576 since 1.6.0. + * ``maxInFlight=0``: int - Maximum number of in-flight queries. The default is 0, which disables out-of-order processing. .. function:: addTLSLocal(address, certFile(s), keyFile(s) [, options]) diff --git a/pdns/dnsdistdist/doq.cc b/pdns/dnsdistdist/doq.cc index 160f3e7ae8..e283a754b4 100644 --- a/pdns/dnsdistdist/doq.cc +++ b/pdns/dnsdistdist/doq.cc @@ -298,10 +298,20 @@ void DOQFrontend::setup() quiche_config_set_max_idle_timeout(config.get(), d_idleTimeout * 1000); quiche_config_set_max_recv_udp_payload_size(config.get(), MAX_DATAGRAM_SIZE); quiche_config_set_max_send_udp_payload_size(config.get(), MAX_DATAGRAM_SIZE); - quiche_config_set_initial_max_data(config.get(), 10000000); - quiche_config_set_initial_max_stream_data_bidi_local(config.get(), 1000000); - quiche_config_set_initial_max_stream_data_bidi_remote(config.get(), 1000000); - quiche_config_set_initial_max_streams_bidi(config.get(), 100); + + // The number of concurrent remotely-initiated bidirectional streams to be open at any given time + // https://docs.rs/quiche/latest/quiche/struct.Config.html#method.set_initial_max_streams_bidi + // 0 means none will get accepted, that's why we have a default value of 65535 + quiche_config_set_initial_max_streams_bidi(config.get(), d_maxInFlight); + + // The number of bytes of incoming stream data to be buffered for each localy or remotely-initiated bidirectional stream + quiche_config_set_initial_max_stream_data_bidi_local(config.get(), 8192); + quiche_config_set_initial_max_stream_data_bidi_remote(config.get(), 8192); + + // The number of total bytes of incoming stream data to be buffered for the whole connection + // https://docs.rs/quiche/latest/quiche/struct.Config.html#method.set_initial_max_data + quiche_config_set_initial_max_data(config.get(), 8192 * d_maxInFlight); + quiche_config_set_cc_algorithm(config.get(), QUICHE_CC_RENO); { diff --git a/pdns/dnsdistdist/doq.hh b/pdns/dnsdistdist/doq.hh index 9cd69fe928..624af04d87 100644 --- a/pdns/dnsdistdist/doq.hh +++ b/pdns/dnsdistdist/doq.hh @@ -53,6 +53,7 @@ struct DOQFrontend uint32_t d_internalPipeBufferSize{0}; #endif uint64_t d_idleTimeout{5}; + uint64_t d_maxInFlight{65535}; }; struct DOQUnit -- 2.47.2