aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2019-08-28 01:41:00 +0200
committerKim Alvefur <zash@zash.se>2019-08-28 01:41:00 +0200
commit4cc299fc0214368012a2775b94c746d2290327a0 (patch)
treee5fd14cd67d67a1e6d6ed75009a8565aa387ab3f /net
parentf39535cfd039d481457c27cee5154bdfb1ff3621 (diff)
downloadprosody-4cc299fc0214368012a2775b94c746d2290327a0.tar.gz
prosody-4cc299fc0214368012a2775b94c746d2290327a0.zip
net.server_epoll: Add support for opportunistic writes
This tries to flush data to the underlying sockets when receiving writes. This should lead to fewer timer objects being around. On the other hand, this leads to more and smaller writes which may translate to more TCP/IP packets being sent, depending on how the kernel handles this. This trades throughput for lower latency.
Diffstat (limited to 'net')
-rw-r--r--net/server_epoll.lua8
1 files changed, 8 insertions, 0 deletions
diff --git a/net/server_epoll.lua b/net/server_epoll.lua
index 49ad48ea..ef021851 100644
--- a/net/server_epoll.lua
+++ b/net/server_epoll.lua
@@ -66,6 +66,9 @@ local default_config = { __index = {
-- EXPERIMENTAL
-- Whether to kill connections in case of callback errors.
fatal_errors = false;
+
+ -- Attempt writes instantly
+ opportunistic_writes = false;
}};
local cfg = default_config.__index;
@@ -413,6 +416,7 @@ function interface:onwritable()
for i = #buffer, 2, -1 do
buffer[i] = nil;
end
+ self:set(nil, true);
self:setwritetimeout();
end
if err == "wantwrite" or err == "timeout" then
@@ -439,6 +443,10 @@ function interface:write(data)
self.writebuffer = { data };
end
if not self._write_lock then
+ if cfg.opportunistic_writes then
+ self:onwritable();
+ return #data;
+ end
self:setwritetimeout();
self:set(nil, true);
end