String callbacks (before_save, after_save, before_destroy, etc.) may significantly slow down the Rails application. The problem is that each such callback is evaluated in the context of AR object and because of that each time the proper binding (Binding object) should be created and passed to the eval method. That is not only slow, but takes a lot of memory leading to more garbage collection calls.
Rails creates quite a lot of such string callbacks for associations. Attached patch rewrites all such string callbacks into method callbacks (defined using define_method). This is not only a lot faster but also consistent with other places in associations.rb where define_method is used.
In my case when creating 100 AR objects (each with 6 associations) that saved 52 Megabytes of memory and 700ms.
Please see my article for details: http://blog.pluron.com/2008/02/rails-faster-as.html