diff options
author | Eric Wong <e@80x24.org> | 2019-06-24 02:52:44 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2019-06-24 05:26:27 +0000 |
commit | 87a03babc14247d4eac489beb95abba47cf4f358 (patch) | |
tree | 6bb1590ed88013a05f97c79cd263c209b5606722 /lib | |
parent | 1dc4d2f75a387c9113fc7646c463e3aac2d3de1f (diff) | |
download | public-inbox-87a03babc14247d4eac489beb95abba47cf4f358.tar.gz |
34K per idle connection adds up to large amounts of memory; especially with the speed of malloc nowadays compared to the cost of cache misses or worse, swapping.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/PublicInbox/Daemon.pm | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/PublicInbox/Daemon.pm b/lib/PublicInbox/Daemon.pm index 55103f40..c4481555 100644 --- a/lib/PublicInbox/Daemon.pm +++ b/lib/PublicInbox/Daemon.pm @@ -59,6 +59,16 @@ sub accept_tls_opt ($) { } my $ctx = IO::Socket::SSL::SSL_Context->new(%ctx_opt) or die 'SSL_Context->new: '.PublicInbox::TLS::err(); + + # save ~34K per idle connection (cf. SSL_CTX_set_mode(3ssl)) + # RSS goes from 346MB to 171MB with 10K idle NNTPS clients on amd64 + # cf. https://rt.cpan.org/Ticket/Display.html?id=129463 + my $mode = eval { Net::SSLeay::MODE_RELEASE_BUFFERS() }; + if ($mode && $ctx->{context}) { + eval { Net::SSLeay::CTX_set_mode($ctx->{context}, $mode) }; + warn "W: $@ (setting SSL_MODE_RELEASE_BUFFERS)\n" if $@; + } + { SSL_server => 1, SSL_startHandshake => 0, SSL_reuse_ctx => $ctx }; } |