]> Sergey Matveev's repositories - public-inbox.git/commitdiff
http: cork chunked responses for small savings
authorEric Wong <e@80x24.org>
Fri, 24 Jun 2016 23:40:03 +0000 (23:40 +0000)
committerEric Wong <e@80x24.org>
Sat, 25 Jun 2016 00:19:37 +0000 (00:19 +0000)
This only affects Linux users with MSG_MORE support.

We can avoid extra TCP overhead for sub-optimal chunk sizes
by using MSG_MORE even with chunk trailers under Linux.

This breaks real-time apps which require <= 200ms latency for
streaming small packets (e.g. implementing "tail -F"), but the
public-inbox WWW code does not (and will never) do such things.

lib/PublicInbox/HTTP.pm

index c141fc896d0538875ca5a76c26c413ec910c4652..e19c592c99612ae29960676e5112166d5f5642eb 100644 (file)
@@ -223,7 +223,10 @@ sub chunked_wcb ($) {
                return if $_[0] eq '';
                more($self, sprintf("%x\r\n", bytes::length($_[0])));
                more($self, $_[0]);
-               $self->write("\r\n");
+
+               # use $self->write("\n\n") if you care about real-time
+               # streaming responses, public-inbox WWW does not.
+               more($self, "\r\n");
        }
 }