]> Sergey Matveev's repositories - public-inbox.git/commit
wwwstatic: wire up buffer bypass for -httpd
authorEric Wong <e@yhbt.net>
Fri, 24 Jan 2020 09:43:52 +0000 (09:43 +0000)
committerEric Wong <e@yhbt.net>
Sat, 25 Jan 2020 19:34:21 +0000 (19:34 +0000)
commitda0bddd3a5c573cd4623d1c95ebf4ee6dd87ed27
treea3dc89216b42ff0393c4889dfc1b12e25df5281a
parentaaf85aef560bc828b6e0fedb5a7632e8c47d7228
wwwstatic: wire up buffer bypass for -httpd

This prevents public-inbox-httpd from buffering ->getline
results from a static file into another temporary file when
writing to slow clients.  Instead we inject the static file
ref with offsets and length directly into the {wbuf} queue.

It took me a while to decide to go this route, some
rejected ideas:

1. Using Plack::Util::set_io_path and having PublicInbox::HTTP
   serve the result directly.  This is compatible with what
   some other PSGI servers do using sendfile.  However, neither
   Starman or Twiggy currently use sendfile for partial responses.

2. Parsing the Content-Range response header for offsets and
   lengths to use with set_io_path for partial responses.

These rejected ideas required increasing the complexity of HTTP
response writing in PublicInbox::HTTP in the common, non-static
file cases.  Instead, we made minor changes to the colder write
buffering path of PublicInbox::DS and leave the hot paths
untouched.

We still support generic PSGI servers via ->getline.  However,
since we don't know the characteristics of other PSGI servers,
we no longer do a 64K initial read in an attempt to negotiate a
larger TCP window.
lib/PublicInbox/WwwStatic.pm