From 902802a8dcec94ec192a517e2bb90267ed2af19b Mon Sep 17 00:00:00 2001 From: Bram Matthys Date: Fri, 3 Oct 2025 15:59:50 +0200 Subject: [PATCH] I/O engine: don't request write notification if we don't need it. In testing with 1000 TLS clients this saves around 16% of unrealircd CPU time (so not 16% CPU, but 16% of whatever % unrealircd cpu is). --- src/socket.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/socket.c b/src/socket.c index 156eae6ed..b604d751c 100644 --- a/src/socket.c +++ b/src/socket.c @@ -1195,8 +1195,13 @@ void read_packet(int fd, int revents, void *data) * it may be overwritten in an earlier call to read_packet(), * to handle (TLS) writes by read_packet(), see below under * SSL_ERROR_WANT_WRITE. + * Update 2025-10-03: actually only restore it to send_queued_cb + * if we actually have anything to send, otherwise set to NULL. */ - fd_setselect(fd, FD_SELECT_WRITE, send_queued_cb, client); + if (DBufLength(&client->local->sendQ) > 0) + fd_setselect(fd, FD_SELECT_WRITE, send_queued_cb, client); + else + fd_setselect(fd, FD_SELECT_WRITE, NULL, client); while (1) {