I just uploaded the first version of the attoparsec-iteratee library to Hackage. It takes applicative parsers written using attoparsec and automagically converts them to iteratees that can parse things from streams in O(1) space.

…and the combination is fast: a prototype HTTP server I’m working on uses this library and can handle as many as 13k reqs/sec on my Macbook:


$ curl -i http://localhost:8000/; echo
HTTP/1.1 200 OK
Content-Length: 4
Date: Sat, 13 Mar 2010 02:55:29 GMT
Server: Snap/0.pre-1

PONG
$ httperf --hog --num-conns 1000 --num-calls 100 --burst-length 20 --port 8000
httperf --hog --client=0/1 --server=localhost --port=8000 --uri=/ ....
httperf: warning: open file limit > FD_SETSIZE; limiting max. # of open files...
Maximum connect burst length: 1

Total: connections 1000 requests 100000 replies 100000 test-duration 7.204 s

Connection rate: 138.8 conn/s (7.2 ms/conn, <=1 concurrent connections)
Connection time [ms]: min 5.5 avg 7.2 max 28.4 median 7.5 stddev 1.5
Connection time [ms]: connect 0.1
Connection length [replies/conn]: 100.000

Request rate: 13880.5 req/s (0.1 ms/req)
Request size [B]: 62.0

Reply rate [replies/s]: min 13896.2 avg 13896.2 max 13896.2 stddev 0.0 (1 samples)
Reply time [ms]: response 0.9 transfer 0.0
Reply size [B]: header 97.0 content 4.0 footer 0.0 (total 101.0)
Reply status: 1xx=0 2xx=100000 3xx=0 4xx=0 5xx=0

CPU time [s]: user 1.24 system 4.95 (user 17.2% system 68.7% total 85.8%)
Net I/O: 2209.5 KB/s (18.1*10^6 bps)

Errors: total 0 client-timo 0 socket-timo 0 connrefused 0 connreset 0
Errors: fd-unavail 0 addrunavail 0 ftab-full 0 other 0