mirror of mongrel-development@rubyforge.org (inactive)
 help / color / mirror / Atom feed
From: "ry dahl" <ry-Xek56AhD01PHviPkdFu9cA@public.gmane.org>
To: mongrel-development-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org
Subject: Re: Pure Ruby HTTP parser
Date: Thu, 24 Apr 2008 13:38:03 +0200	[thread overview]
Message-ID: <3ae7f4480804240438g62ed7190if2a84ff08dd2fe34@mail.gmail.com> (raw)
In-Reply-To: <c7e6b2b00804231750o1c86d377i25c83d5e99f41dd1-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>

One could replace http11's parser with some regular expressions and
out-of-bounds checking rather easily. I think Kirk Haines did this (?)
and said it was rather comparable in speed to the C/Ragel state
machine. I guess that wasn't really the point of your exercise, but
it's worth noting, if anyone actually wants a pure ruby http parser.

ry


On Thu, Apr 24, 2008 at 2:50 AM, Tony <tony-INw5wk3xIkAIjDr1QQGPvw@public.gmane.org> wrote:
> Before anything else, let me state this: Of course it's going to be
> PAINFULLY slow on MRI.  That's not the point :)
>
> I thought I'd try out writing out a Ruby version of the parser for the
> purposes of Rubinius.  For those of you who aren't aware, Ragel supports a
> goto-driven FSM on Rubinius by injecting assembly directly, and Rubinus head
> honcho guy Evan Phoenix is working on a patch for Ragel to update it to the
> new compiler semantics.  So really, there is a purpose for trying this out.
>
> Anyway, here's my initial hack.  It's nasty, and presently jams the entire
> FSM into instance-specific data.  Aieee!  But it more or less seems to
> generate similar (albeit not identical) output to the C one:
>
> http://git.rubini.us/?p=code;a=blob;f=lib/mongrel/http11_parser.rb.rl;h=508f9bd42b4aad322f357637d52576f780707a2f;hb=868732662abbf4aa571bf2f3d598152467f6f4da
>
> I've thought about having a Mongrel::HttpParser::FSM module to store the
> actual Ragel-generated state machine, and pass all ivars from the
> Mongrel::HttpParser to an execute method then recapture them as return
> values, or something to that effect.
>
> Thoughts?  Suggestions?  Complete rewrites?  I'd appreciate them all.
>
> --
> Tony Arcieri
> medioh.com
> _______________________________________________
>  Mongrel-development mailing list
>  Mongrel-development-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org
>  http://rubyforge.org/mailman/listinfo/mongrel-development
>
>

  parent reply	other threads:[~2008-04-24 11:39 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-24  0:50 Pure Ruby HTTP parser Tony
     [not found] ` <c7e6b2b00804231750o1c86d377i25c83d5e99f41dd1-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-04-24 11:38   ` ry dahl [this message]
     [not found]     ` <3ae7f4480804240438g62ed7190if2a84ff08dd2fe34-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-04-26 23:33       ` Tony
     [not found]         ` <c7e6b2b00804261633y2835329eqaa1b0190e19f59ac-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-04-26 23:57           ` Luis Lavena
2008-05-06  6:27       ` Zed A. Shaw
replies disabled, historical list

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).