[web-devel] [WAI] Switching to WAI/Warp...

Bardur Arantsson spam at scientician.net
Sun Feb 20 10:04:29 CET 2011


Hi all,

I've recently switched my "Hums" UPnP server over to using WAI/Warp, but 
I'm seeing quite high CPU usage compared to monadic I/O. (1-7% with WAI 
as opposed to 0-1% for monadic).

(Just to be clear: The server is using a constant amount of memory, so 
it's definitely not leaking or anything like that.)

I think the source of the efficiency problem is that I'm enumerating 
strict ByteStrings from a file, but the WAI response enumerator requires 
Builder chunks, so I'm forced to use "fromByteString" to convert between 
the strict ByteString representation and the Builder representation -- 
I'm assuming this performs a memory copy.

Is there any way to avoid this extra "fromByteString"?

Other than this little issue, WAI seems to be working very well and it 
seems like a great fit if you just want low-level access to the HTTP 
protocol.

On a slightly related note: Is there an elegant way to map enumerator 
chunk elements from type a -> b using a mapping function? Right now, 
I've embedded the ByteString -> Builder conversion deep in my 
enumerator, but it should really be happening at a higher level.

Cheers,

Bardur




More information about the web-devel mailing list