[web-devel] API change request for WAI

Michael Snoyman michael at snoyman.com
Fri Jun 3 13:54:23 CEST 2011


On Fri, Jun 3, 2011 at 10:40 AM, Kazu Yamamoto <kazu at iij.ad.jp> wrote:
> Hello,
>
> I would like ask to change WAI API a bit. Please include
> the following data constructor for Response:
>    ResponseIO Status ResponseHeaders (Socket -> IO Bool)
>
> # Please choose better name than ResponseIO

ResponseSocket?

> The function whose type is Socket -> IO Bool is to send a HTTP body to
> the socket and returns keepalive-or-not. This opens possibilities to
> find a better sending scheme than that which Warp adopts by default.
>
> I'm implementing a classical web server library on WAI
> (wai-app-file-cgi). It sends files to clients with ResponseFile.
> Warp uses the sendfile library for ResponseFile.
>
> The sendfile library uses (unnecessary) hSeek and hFileSize which call
> system calls. System calls causes context switches. Since GHC7's IO
> manager uses a single kernel thread, all Haskell threads stops.
> Calling system calls gives significant performance impact.
>
> ResponseIO enables to choose a function which sends files with minimum
> system calls for WAI users.
>
> I have already implemented this both in wai and warp, and confirmed
> that this works well.

Obviously getting sendfile and Warp to be more efficient should be a
goal here (which I know you're already following up on). My question
is, barring issues with the sendfile package, is there any other use
case for this constructor? I'm hesitant to add it, because it does not
have a natural implementation for anything but a standalone server
(i.e., CGI, FastCGI, wai-test will always have trouble with this). I
just want to clarify the need before we make any changes.

Michael



More information about the web-devel mailing list