The first Living on the Edge covered some of the API changes since Rails 2.1, and this time round, I’m going to cover the performance improvements as promised.
Jumping right in…
Faster Erb templates
Jeremy Kemper has made the Erb processing more efficient, especially the concat and capture helper methods.
The “special” Erb
_erbout has been replaced with an instance variable, which allows for:
- better (memory) performance because bindings are no longer being passed around,
- fewer eval
s which are usually expensive,
- there’s no need to slice the
_erbout variable when you can swap in a new (string) buffer, and
- the buffer is actually available via a
output_buffer reader and writer methods (so you can override it if you want).
Relevant changesets: 933697a
RecordIdentifier methods speedup
The RecordIdentifier has been sped up by some simple use of memo-ization, thus reducing the number of inflections performed, among other things. The RecordIdentifier is used widely in cache keys, partial template paths, and in most places where you identify an ActiveRecord model without caring about its actual
Relevant changesets by Jeremy Kemper: c1a9820 – 566d717
Lazy load cache and session stores
Update: Oops my bad, this change was later reverted in 6573f6a.
The various cache stores in the ActiveSupport::Cache module are now lazy loaded – this means that they are only
required when you actually start using them.
Changeset by Pratik Naik