[web-devel] API change request for WAI

Kazu Yamamoto ( 山本和彦 ) kazu at iij.ad.jp
Fri Jun 3 09:40:29 CEST 2011


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

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.

--Kazu



More information about the web-devel mailing list