[web-devel] ResponseEnumerator
Erik de Castro Lopo
mle+hs at mega-nerd.com
Tue Dec 13 09:02:36 CET 2011
Michael Snoyman wrote:
> It's a good question. The advantage of a Builder is that we get cheap
> concatenation, so you can create a stream of smaller ByteStrings and
> then Warp will automatically concatenate them together into larger
> chunks. There are a few claims against this:
>
> Q1. Shouldn't it be at the user's discretion to use Builders
> internally and then create a stream of ByteStrings?
> A1. That would be less efficient, as we wouldn't get cheap
> concatenation with the response headers.
>
> Q2. Isn't it really inefficient to convert from ByteString to Builder,
> and then right back to ByteString?
> A2. No. If the ByteStrings are small, then they will be copied into a
> larger buffer, which should be a performance gain overall (less system
> calls). If they are already large, then blaze-builder uses an
> InsertByteString instruction to avoid copying.
>
> Q3. Doesn't this prevent us from creating comet-style servers, since
> data will be cached?
> A3. You can force blaze-builder to output a ByteString before it is an
> optimal size by sending a flush command.
>
> If these answers make sense, I'll add them to the WAI docs.
+1
Cheers,
Erik
--
----------------------------------------------------------------------
Erik de Castro Lopo
http://www.mega-nerd.com/
More information about the web-devel
mailing list