Skip to content
Snippets Groups Projects
Verified Commit 71947f19 authored by Vladimír Čunát's avatar Vladimír Čunát
Browse files

daemon: drop RECVMMSG_BATCH

The support hasn't landed in libuv over all the years,
and we've been still reserving memory for it in advance.
Also comment on the singleton buffer usage.
parent b350d38d
No related branches found
No related tags found
1 merge request!675daemon: attempt of refactoring
......@@ -34,7 +34,7 @@
# endif
#endif
#ifndef RECVMMSG_BATCH
#define RECVMMSG_BATCH 4
#define RECVMMSG_BATCH 1
#endif
#ifndef QUERY_RATE_THRESHOLD
#define QUERY_RATE_THRESHOLD (2 * MP_FREELIST_SIZE) /**< Nr of parallel queries considered as high rate */
......
......@@ -36,11 +36,12 @@
static void check_bufsize(uv_handle_t* handle)
{
return; /* TODO: resurrect after https://github.com/libuv/libuv/issues/419 */
/* We want to buffer at least N waves in advance.
* This is magic presuming we can pull in a whole recvmmsg width in one wave.
* Linux will double this the bufsize wanted.
*/
const int bufsize_want = RECVMMSG_BATCH * 65535 * 2;
const int bufsize_want = 2 * sizeof( ((struct worker_ctx *)NULL)->wire_buf ) ;
negotiate_bufsize(uv_recv_buffer_size, handle, bufsize_want);
negotiate_bufsize(uv_send_buffer_size, handle, bufsize_want);
}
......
......@@ -270,6 +270,14 @@ int session_set_handle(struct session *session, uv_handle_t *handle)
session->wire_buf = wire_buf;
session->wire_buf_size = KNOT_WIRE_MAX_PKTSIZE;
} else if (handle->type == UV_UDP) {
/* We use the singleton buffer from worker for all UDP (!)
* libuv documentation doesn't really guarantee this is OK,
* but the implementation for unix systems does not hold
* the buffer (both UDP and TCP) - always makes a NON-blocking
* syscall that fills the buffer and immediately calls
* the callback, whatever the result of the operation.
* We still need to keep in mind to only touch the buffer
* in this callback... */
assert(handle->loop->data);
struct worker_ctx *worker = handle->loop->data;
session->wire_buf = worker->wire_buf;
......
......@@ -127,11 +127,8 @@ struct worker_ctx {
struct sockaddr_in out_addr4;
struct sockaddr_in6 out_addr6;
#if __linux__
uint8_t wire_buf[RECVMMSG_BATCH * KNOT_WIRE_MAX_PKTSIZE];
#else
uint8_t wire_buf[KNOT_WIRE_MAX_PKTSIZE];
#endif
struct {
size_t concurrent;
size_t rconcurrent;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment