michael at snoyman.com
Thu Jun 16 20:29:51 CEST 2011
On Wed, Jun 15, 2011 at 4:43 AM, Kazu Yamamoto <kazu at iij.ad.jp> wrote:
> I have uploaded the simple-sendfile package to HackageDB.
> This is a simple version of the sendfile package which use unnecessary
> system calls (stat() and lseek()).
> The simple-sendfile package provides native sendfile support for
> Linux, BSDs, and MacOS. For other OSes, a fallback function using
> read()/send () is provided.
> Since the limitation of sendfile on Linux, stat() is called if
> EntireFile is used. But we can use PartOfFile instead to send entire
> I modified Warp to make use of the simple-sendfile package.
> And I confirmed that performance becomes much better. I'm very
> satisfied with the current performance.
> Since I don't know how T.Handle should be used, the commit above just
> ignores T.Handle at this moment. If necessary, I would love to modify
> the API of the simple-sendfile package.
> web-devel mailing list
> web-devel at haskell.org
Looks good, I'd love to merge this. I think the only thing we'd need
modified to the simple-sendfile API is to accept a callback that's
triggered each time a chunk is sent over the stream. How about:
sendfile :: Socket -> FilePath -> FileRange -> IO () -> IO ()
Though it seems that you currently aren't doing any chunking, so
there's no way to tickle the timeout. This will work fine for small
files, but sending 2GB files will result in timeouts, unless we
disable timeouts for all sendfile calls. But of course that opens us
to slowloris attacks.
I know it will hurt performance a bit, but what do you think of
changing simple-sendfile to send in smaller chunks?
More information about the web-devel