1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/guides
Simon Coffey eede8d8130 Add action_view.finalize_compiled_template_methods config option
ActionView::Template instances compile their source to methods on the
ActionView::CompiledTemplates module. To prevent leaks in development
mode, where templates can frequently change, a finalizer is added that
undefines these methods[1] when the templates are garbage-collected.

This is undesirable in the test environment, however, as templates don't
change during the life of the test. Moreover, the cost of undefining a
method is proportional to the number of descendants a class or module
has, since the method cache must be cleared for all descendant classes.

As ActionView::CompiledTemplates is mixed into every
ActionView::TestCase (or in RSpec suites, every view spec example
group), it can end up with a very large number of descendants, and
undefining its methods can become very expensive.

In large test suites, this results in a long delay at the end of the
test suite as all template finalizers are run, only for the process to
then exit.

To avoid this unnecessary cost, this change adds a config option,
`action_view.finalize_compiled_template_methods`, defaulting to true,
and sets it to false in the test environment only.

[1] 09b2348f7f/actionview/lib/action_view/template.rb (L118-L126)
2018-04-02 20:50:33 +01:00
..
assets Remove needless images in guides 2018-03-31 23:51:27 +09:00
bug_report_templates Update bug report templates 2018-02-17 22:53:14 -08:00
rails_guides Not generate needless files in guides 2018-04-02 18:30:23 +09:00
source Add action_view.finalize_compiled_template_methods config option 2018-04-02 20:50:33 +01:00
.document
CHANGELOG.md Remove changelog header for unreleased version 2018-03-13 15:20:57 -04:00
rails_guides.rb Use frozen string literal in guides/ 2017-08-13 22:04:09 +09:00
Rakefile Use frozen string literal in guides/ 2017-08-13 22:04:09 +09:00
w3c_validator.rb Use frozen string literal in guides/ 2017-08-13 22:04:09 +09:00