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.

Callbacks static analysis optimizations

#1660

ActiveSupport::Callbacks are used though out Rails so any micro-optimizations "may" go a long way.

At the moment, the callback's object is checked every time the callback is run, see Callback#evaluate_method. But we do know the type of this object when the callback object is created.

The idea is to have Callback#initialize generate a the "Callback#call" method (omg metaprogramming) that runs the conditionals :if/:unless then fires the callback.

Reported by josh · December 28th, 2008 @ 09:03 PM

State: stale
Milestone: 3.0.2
Assigned to: Yehuda Katz (wycats) Yehuda Katz (wycats)
Importance: Medium

Activity

  1. Yehuda Katz (wycats)
  2. Scott Taylor
    Scott Taylor
    • Tag set to optimisation, patch

    Here's a patch which does some static analysis and other cleanup to the callbacks. The code is also more OO-ish, and cleaner, IMHO.

    I've attached a series of 9 patches as tarball (generated with git-format-patch) - some include benchmarks, some include misc. cleanup. I've left it as a tarball so that you can pick and choose what you like.

    Let me know if you'd prefer one big unified diff.

    February 1st, 2009 @ 04:56 AM

  3. Yehuda Katz (wycats)
    Yehuda Katz (wycats)

    I actually did a ton of work related to this ticket, completely rewriting the callback system and making it between 10-20x faster. I also added around filters, skipping, and a per-key optimization for ActionPack callbacks. You can see the work I'm doing at http://github.com/wycats/rails/t... and some posts detailing the work I'm doing at http://yehudakatz.com/.

    >

    February 2nd, 2009 @ 04:00 PM

  4. Pratik
    Pratik
    • State changed from new to stale

    April 21st, 2009 @ 03:28 PM

  5. Jeremy Kemper
    Jeremy Kemper
    • Milestone set to 3.0.2
    • Importance changed from to Medium

    October 15th, 2010 @ 11:01 PM