hi, I rewrote escape, unescape, and query_parse in a C extension. http://s3.amazonaws.com/four.livejournal/20070922/http_helpers.tar.bz2 Here are some sample benchmarks (the benchmark script is included in the package) user system total real escape: Single long Mongrel: 1.680000 0.020000 1.700000 ( 1.837793) HttpHlp: 0.030000 0.010000 0.040000 ( 0.036590) escape: Many small Mongrel: 2.580000 0.020000 2.600000 ( 2.751985) HttpHlp: 0.290000 0.010000 0.300000 ( 0.353808) unescape: Single long Mongrel: 2.490000 0.030000 2.520000 ( 2.659217) HttpHlp: 0.030000 0.010000 0.040000 ( 0.238297) unescape: Many small Mongrel: 3.400000 0.030000 3.430000 ( 3.952430) HttpHlp: 0.280000 0.000000 0.280000 ( 0.344116) query_parse: one long query Merb: 0.350000 0.010000 0.360000 ( 0.518884) HHlp: 0.020000 0.000000 0.020000 ( 0.023698) query_parse: many short query strings Merb: 5.970000 0.060000 6.030000 ( 7.105239) HHlp: 0.710000 0.010000 0.720000 ( 0.893846) query_parse: deeply nested query Merb: 0.000000 0.000000 0.000000 ( 0.000242) HHlp: 0.000000 0.000000 0.000000 ( 0.000047) My query_parse implements a different behavior than Mongrel has. Mongrel interprets "q[a]=b" to be { ''q[a]'' => ''b'' }. Instead the C extension mimic''s Merb''s behavior, creating nested hashes. I think mongrel should change the behavior of it''s query_parse function and use a C implementation. HttpHelpers.query_parse also uses a ragel state machine, so it shouldn''t be increadably hard to put this query_parse directly into http11. Is there a development branch of mongrel? What should I patch against? What do people feel about how query_parse should behave? Should it happen automatically as Mongrel parses the rest of the query? Should it by default use the Merb hash syntax? ry
On Sat, 22 Sep 2007 19:59:57 +0200 "ry dahl" <ry at tinyclouds.org> wrote:> hi, > > I rewrote escape, unescape, and query_parse in a C extension. > http://s3.amazonaws.com/four.livejournal/20070922/http_helpers.tar.bz2I''ll take a look at this during the weekend and check the code. So far the benchmarks are good so I''ll talk with the mongrel team and see what they think. Are you actively using this?> > My query_parse implements a different behavior than Mongrel has. > Mongrel interprets "q[a]=b" to be { ''q[a]'' => ''b'' }. Instead the C > extension mimic''s Merb''s behavior, creating nested hashes.I think that works for Merb and your stuff, but Rails expects the cgi.rb flavor (which isn''t correct, your''s is). Have you tried it with rails yet?> I think mongrel should change the behavior of it''s query_parse > function and use a C implementation. HttpHelpers.query_parse also uses > a ragel state machine, so it shouldn''t be increadably hard to put this > query_parse directly into http11.That''s entirely true, but let me double check your C. If I find a buffer overflow you owe me a pizza. :-)> > Is there a development branch of mongrel? What should I patch against?Go join the development list. I''m starting to slowly come out of hiding and will be working to direct the mongrel team volunteers as they try to push out 1.0.2. There''s no development branch, but we could try to work this in. http://rubyforge.org/mailman/listinfo/mongrel-development> What do people feel about how query_parse should behave? Should it > happen automatically as Mongrel parses the rest of the query? Should > it by default use the Merb hash syntax?Now, you did this with Ragel, what about merging the parsing into the existing http11 parser to do this all inline and on the fly? That way, when it comes out it''s C coma it''s got a fully cooked response. -- Zed A. Shaw - Hate: http://savingtheinternetwithhate.com/ - Good: http://www.zedshaw.com/ - Evil: http://yearofevil.com/
Hi Zed, this isn''t ready to just be inserted into Mongrel as it is. I just wrote it for fun/to see if I could make Merb faster/to learn ragel. I thought I would clean it up and reformat it if y''all were interested - it has several crashing problems and it doesn''t work with cookies yet.> I''m starting to slowly come out of hiding and > will be working to direct the mongrel team volunteers as they try to push out 1.0.2.glad to hear it ry