Routes recognition 2-3x speedup patch

Hi there!

Recently i've been playing with an idea of really fast routes matching and got 8.8x performance boost, implementing 90% of routing features (comparing with ActionPack 2.0.2).

However, porting was a bit hard (not to say a real mess), so i've applied a smaller optimisation (mostly sitting in a separate file, what's really rocks) and got 2..3 times recognition speed boost for vkadre.ru. In practice it means, that you can get up to 20-30% overall performance improvement. Actual benefit depends on your app design, for slow actions and/or tiny routes.rb it will be, of course, lower.

Here's a story about it (please read, there are important notes): http://novemberain.com/2008/1/17/routes-recognition

Here's the patch: http://dev.rubyonrails.org/ticket/10835

I'd like you to test the patch on your routes and report performance characteristics before and after. (See a link to benchmark raketask inside article)

I hope, many guys would check this out and we get it applied into trunk. Rails really deserves optimization in such kind of code.

Thanks. Oleg Andreev (oleganza)

PS. Don't test it on a single pattern ":controller/:action/:id". It does not improve speed in that case, but only adds a 30% overhead. Old actionpack routing benchmark uses single pattern for recognition testing, so it will show that things go slower rather than faster.

I hope, many guys would check this out and we get it applied into trunk. Rails really deserves optimization in such kind of code.

Thanks again for your awesome work so far. I'll apply the first part of your patch which splits up routing.rb into some more manageable chunks.

Let's keep hashing this out on IRC and see if we can get the full optimisation applied to actionpack.