Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Fix for routing optimization code

#981

Related info: http://dev.rubyonrails.org/ticke... - original patch http://hobo.lighthouseapp.com/pr... - observed failure

The routing optimization code introduced by #10835 above has a serious bug - it only generates the recognize_optimized method once. This causes errors when routes are reloaded - if any are different, then the generated indexing code is not correct.

The changes in commit a5db1488251304ec93256654859b430148f0c506 caused the code to be generated at initialization, when no routes were loaded. While this prevents the above bug, it converts the efficient search intended by #10835 back into a linear search of all routes.

The attached patch re-enables efficient search while clearing the generated code when the routes are reloaded. A test for correct code generation is included - it fails on the 2.1.0 version.

--Matt Jones

Reported by Matt Jones · September 6th, 2008 @ 12:08 PM

State: resolved
Milestone: 2.1.2
Assigned to: josh josh
Importance: High

Activity

  1. Matt Jones
    Matt Jones
    • Tag set to actionpack, bug, patch, routing, tested

    Forgot to include the timing info:

    Before change: Generation (RouteSet): (40000 urls) 0.0556527018547058 ms/url 17968.5795419372 url/s

    Recognition (215 routes): 0.258163173993429 ms/url 3873.5191566302 url/s

    After change: Generation (RouteSet): (40000 urls) 0.0557102739810944 ms/url 17950.0104476125 url/s

    Recognition (215 routes): 0.0320691665013631 ms/url 31182.6002698728 url/s

    (from routing_test.rb timing test)

    September 6th, 2008 @ 12:10 PM

  2. Pratik
    Pratik
    • Assigned user set to Michael Koziarski

    September 6th, 2008 @ 01:05 PM

  3. Michael Koziarski
    Michael Koziarski
    • Assigned user changed from Michael Koziarski to josh

    This looks ok to me, I don't have reliable internet for a few days.

    Josh, can you take care of this?

    September 6th, 2008 @ 04:43 PM

  4. Michael Koziarski
    Michael Koziarski
    • Milestone changed from 2.x to 2.1.2

    September 6th, 2008 @ 04:57 PM

  5. Michael Koziarski
    Michael Koziarski

    Matt, could you upload a 2-1-stable friendly version of this patch

    September 6th, 2008 @ 05:00 PM

  6. Matt Jones
    Matt Jones

    As requested - patch against 2-1-stable.

    Performance for this case is identical before/after, the slowdown was in trunk.

    September 6th, 2008 @ 09:07 PM

  7. Repository
    Repository
    • State changed from new to resolved

    (from [7e6cda15f8dae517f9605f73aa1c966a29d4930a]) Ensure routing optimizations are cleared when new routes are added [#981 state:resolved] Signed-off-by: Joshua Peek josh@joshpeek.com http://github.com/rails/rails/co...

    September 7th, 2008 @ 04:30 PM

  8. Repository
    Repository

    (from [d4ef5908edfd471dfd3635a7264b5f8aafe246b6]) Ensure routing optimizations are cleared when new routes are added [#981 state:resolved] Signed-off-by: Joshua Peek josh@joshpeek.com http://github.com/rails/rails/co...

    September 7th, 2008 @ 04:33 PM