aboutsummaryrefslogtreecommitdiffstats
path: root/net/server_epoll.lua
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
commit6d1272823e56321129de933588947dab1180aa6b (patch)
treee5fd14cd67d67a1e6d6ed75009a8565aa387ab3f /net/server_epoll.lua
parent60733a4006c9dab2e1df60b4ff75d6844b926c4e (diff)
downloadprosody-6d1272823e56321129de933588947dab1180aa6b.tar.gz
prosody-6d1272823e56321129de933588947dab1180aa6b.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/server_epoll.lua')
-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