[Mongrel-development] [PATCH] http11: ~6% performance increase in header parsing

Eric Wong normalperson at yhbt.net
Sat Mar 8 03:12:10 EST 2008


ry dahl <ry at tinyclouds.org> wrote:
> Hi Eric,
> 
> >  I'm getting an even bigger (~22%) performance
> > improvement by predefining
> >  some common HTTP headers as global frozen
> > strings upfront (r992)
> 
> Why don't you do this in Ragel? It will be faster and you don't need
> to depend on bsearch. I pull out content-length header in ragel in
> ebb:
>  http://github.com/ry/ebb/tree/master/src/parser.rl
> (although there is a bug with this because (content_length |
> message_header ) needs some priorities set so message_header isn't
> matching content-length too. should be
>    (content_length >2 | message_header >1 )
> or something).

Then I'd have to define a new C function for every header I wanted to
optimize for, and then also point to that function inside the Ragel file
for each header.

Unless we use something like ERB to generate this code for both Ragel
and C, I'm not sure it's worth the effort to go through with all the
extra code.

Currently, with my C/CPP code, I can add or remove headers to memoize
strings for by adding or removing one line per header in the C file.
Pretty much as easy as it gets maintenance-wise.

> Also - the state machine should be upgraded to compile with ragel 6.
> this basically involves removing %write eof;

Yes.  At the same time, I'm not sure if I should force every other
developer to upgrade... Evan?  Zed?

-- 
Eric Wong


More information about the Mongrel-development mailing list