Visitar URL original
`render_in`: Skip emission of `render_template.action_view` by joelhawksley · Pull Request #3 · joelhawksley/rails · GitHub
Skip to content

render_in: Skip emission of render_template.action_view - #3

Closed
joelhawksley wants to merge 1 commit into
mainfrom
joelhawksley-draft-pr-for-rails
Closed

joelhawksley wants to merge 1 commit into
mainfrom
joelhawksley-draft-pr-for-rails

Conversation

@joelhawksley

Copy link
Copy Markdown
Owner

Motivation

Related to rails#57781.

Rendering objects that implement render_in now emits render_template.action_view notifications, contributing to increased allocations in ViewComponent-heavy pages after rails#50623.

Changes

Instantiate ActionView::Template::Renderable and invoke render directly instead of routing renderable objects through ActionView::Renderer. This preserves support for passing locals and blocks without emitting the outer render_template.action_view notification.

Includes regression coverage for both render(object) and render(renderable: object).

Attribution

This draft carries Sean Doyle's original commit, unchanged, from seanpdoyle/rails:issue-57781 (f5f01f5d07f345265db205f4862e993b0b82cf39), submitted via joelhawksley/rails.

Validation

Tests have not been run as part of opening this draft.

Related to rails#57781

As reported in rails#57781, new calls to `#render_in` emit
`render_template.action_view` Active Support notifications, which
themselves cause a spike in object allocations.

This commit explores an alternative that preserves the behavior
introduced in [rails#50623][] (support for passing `:locals` at the
`#render_in` call-site) without also emitting
`render_template.action_view` notifications.

Rather than rely on the `ActionView::Renderer` instance returned by the
`ActionView::Helpers::RenderingHelper#view_renderer` invocation,
construct an instance of `Template::Renderable` and invoke `#render` on
it directly.

[rails#50623]: rails#50623
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants