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

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


I'm now tuning warp. 


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


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):


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


More information about the web-devel mailing list