From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eric Wong Newsgroups: gmane.comp.lang.ruby.mongrel.devel Subject: Re: [PATCH] http11: ~6% performance increase in header parsing Date: Sat, 8 Mar 2008 00:12:10 -0800 Message-ID: <20080308081210.GA30702@hand.yhbt.net> References: <20080229015309.GA9080@untitled> <20080303044659.5a550c19.zedshaw@zedshaw.com> <20080302123712.GA13979@hand.yhbt.net> <20080306075421.GA1583@hand.yhbt.net> <3ae7f4480803060153v18e955a5j9038f93e558f81d1@mail.gmail.com> Reply-To: mongrel-development-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1204963966 21779 80.91.229.12 (8 Mar 2008 08:12:46 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 8 Mar 2008 08:12:46 +0000 (UTC) To: mongrel-development-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org Original-X-From: mongrel-development-bounces-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org Sat Mar 08 09:13:06 2008 Return-path: Envelope-to: gclrmd-mongrel-development@m.gmane.org Content-Disposition: inline In-Reply-To: <3ae7f4480803060153v18e955a5j9038f93e558f81d1-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> User-Agent: Mutt/1.5.13 (2006-08-11) X-BeenThere: mongrel-development-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org X-Mailman-Version: 2.1.9 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: mongrel-development-bounces-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org Errors-To: mongrel-development-bounces-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org Xref: news.gmane.org gmane.comp.lang.ruby.mongrel.devel:1 Received: from rubyforge.org ([205.234.109.19]) by lo.gmane.org with esmtp (Exim 4.50) id 1JXuAz-0006xi-SA for gclrmd-mongrel-development@m.gmane.org; Sat, 08 Mar 2008 09:13:06 +0100 Received: from rubyforge.org (rubyforge.org [127.0.0.1]) by rubyforge.org (Postfix) with ESMTP id 9865018586B7; Sat, 8 Mar 2008 03:12:30 -0500 (EST) Received: from hand.yhbt.net (hand.yhbt.net [66.150.188.102]) by rubyforge.org (Postfix) with ESMTP id 378C818585E5 for ; Sat, 8 Mar 2008 03:12:12 -0500 (EST) Received: from localhost.localdomain (localhost [127.0.0.1]) by hand.yhbt.net (Postfix) with ESMTP id BEE8D7F4153; Sat, 8 Mar 2008 00:12:11 -0800 (PST) List-Post: ry dahl 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