[web-devel] new field for Network.HTTP.Types.Status

Kazu Yamamoto ( 山本和彦 ) kazu at iij.ad.jp
Fri Aug 17 10:23:04 CEST 2012


Hello,

I'm now tuning warp. 

	https://github.com/kazu-yamamoto/wai/tree/refactoring/warp

One of bottlenecks is the code to compose HTTP header. I have already
rewritten the code using direct memory copy instead of BlazeBuilder.

	https://github.com/kazu-yamamoto/wai/blob/refactoring/warp/Network/Wai/Handler/Warp/ResponseHeader.hs

This code gain around 2,000 req/s on my machine. In this code, you can
find two 'divMod' and one 'mod'. These is to convert numeric HTTP
status code to ByteString. 

It appeared this conversion is slow. Note that due to a bug of GHC,
five (not three) divisions are carried out.

So, I redefined Network.HTTP.Types.Status to have reformatted
ByteString for status code (the statusAsciiCode field):

	https://github.com/kazu-yamamoto/http-types/blob/status-ascii-code/Network/HTTP/Types/Status.hs

This hack gains also around 2,000 req/s.

This change breaks compatibilities. I found that warp, http-conduit,
wai-app-file-cgi are affected.

So, my question: is this hack acceptable? If not, I will define a
large array of ByteString in warp. But it seems to me that this is
nonsense.

--Kazu



More information about the web-devel mailing list