about summary refs log tree commit homepage
path: root/t
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2019-07-05 22:53:39 +0000
committerEric Wong <e@80x24.org>2019-07-06 04:33:39 +0000
commita3c054cbbf2a51be121b3237c5d223acc5c8a2f4 (patch)
tree7ea4e22652ad3063d6cc84c39a3aec4cacbf4eb6 /t
parent77c66b4cdb1d52321ed3cb6352fe0b72312cbb71 (diff)
downloadpublic-inbox-a3c054cbbf2a51be121b3237c5d223acc5c8a2f4.tar.gz
Using Z_FULL_FLUSH at the right places in our event loop, it
appears we can share a single zlib deflate context across ALL
clients in a process.

The zlib deflate context is the biggest factor in per-client
memory use, so being able to share that across many clients
results in a large memory savings.

With 10K idle-but-did-something NNTP clients connected to a
single process on a 64-bit system, TLS+DEFLATE used around
1.8 GB of RSS before this change.  It now uses around 300 MB.
TLS via IO::Socket::SSL alone uses <200MB in the same situation,
so the actual memory reduction is over 10x.

This makes compression less efficient and bandwidth increases
around 45% in informal testing, but it's far better than no
compression at all.  It's likely around the same level of
compression gzip gives on the HTTP side.

Security implications with TLS?  I don't know, but I don't
really care, either...  public-inbox-nntpd doesn't support
authentication and it's up to the client to enable compression.
It's not too different than Varnish caching gzipped responses
on the HTTP side and having responses go to multiple HTTPS
clients.
Diffstat (limited to 't')
-rw-r--r--t/nntpd-validate.t8
1 files changed, 7 insertions, 1 deletions
diff --git a/t/nntpd-validate.t b/t/nntpd-validate.t
index 1a325105..532ef729 100644
--- a/t/nntpd-validate.t
+++ b/t/nntpd-validate.t
@@ -112,11 +112,17 @@ sub do_get_all {
                         }
                 }
         }
+
+        # hacky bytes_read thing added to Net::NNTP for testing:
+        my $bytes_read = '';
+        if ($nntp->can('bytes_read')) {
+                $bytes_read .= ' '.$nntp->bytes_read.'b';
+        }
         my $q = $nntp->quit;
         print STDERR "# quit failed: ".$nntp->code."\n" if !$q;
         my $elapsed = sprintf('%0.3f', clock_gettime(CLOCK_MONOTONIC) - $t0);
         my $res = $dig->hexdigest;
-        print STDERR "# $desc - $res (${elapsed}s)\n";
+        print STDERR "# $desc - $res (${elapsed}s)$bytes_read\n";
         $res;
 }
 my @tests = ([]);