Compile non-strict templates Ractor-locally - #62
Open
etiennebarrie wants to merge 2 commits into
Open
Conversation
etiennebarrie
force-pushed
the
actionview-eager-load-templates
branch
from
August 4, 2026 15:42
4d95b86 to
b262f80
Compare
etiennebarrie
force-pushed
the
actionview-frozen-non-strict-templates
branch
from
August 4, 2026 15:43
7f94f80 to
0940ce5
Compare
gmcgibbon
reviewed
Aug 5, 2026
|
|
||
| # Do not escape templates of these mime types. | ||
| class_attribute :escape_ignore_list, default: ["text/plain"] | ||
| class_attribute :escape_ignore_list, default: ["text/plain"].freeze |
Member
There was a problem hiding this comment.
This was solved upstream with an after_initialize freeze I believe.
| # freeze from leaking into other tests. | ||
| ActiveSupport::Ractors.make_shareable(Mime.instance_variable_get(:@lookup_by_extension)) | ||
|
|
||
| r = ActionView::FileSystemResolver.new(dir) |
Member
There was a problem hiding this comment.
Suggested change
| r = ActionView::FileSystemResolver.new(dir) | |
| resolver = ActionView::FileSystemResolver.new(dir) |
Minor comments. I think we can open these upstream.
etiennebarrie
force-pushed
the
actionview-eager-load-templates
branch
from
August 6, 2026 10:33
b262f80 to
93519a3
Compare
etiennebarrie
force-pushed
the
actionview-frozen-non-strict-templates
branch
from
August 6, 2026 10:33
0940ce5 to
4f4d19a
Compare
etiennebarrie
force-pushed
the
actionview-eager-load-templates
branch
from
August 6, 2026 14:05
93519a3 to
9414c43
Compare
etiennebarrie
force-pushed
the
actionview-frozen-non-strict-templates
branch
from
August 6, 2026 14:05
4f4d19a to
d4c0aa3
Compare
UnboundTemplate#freeze required strict locals because a single template can serve every locals set only when the template ignores render-time locals. Without strict locals, one template exists per locals set, which cannot be known at boot: freeze now keeps the unbound shell frozen and shareable, and bind_locals builds unfrozen templates on demand in a Ractor-local two-level cache (store_if_absent, keyed by the unbound template then by normalized locals). Each Ractor compiles a locals set at most once, mirroring the per-process behavior of the unfrozen cache. Requires concurrent-ruby 1.3.8, which froze the Concurrent::NULL sentinel that every Concurrent::Map operation reads. The Ractor test compiles through the private compile method: ActiveSupport::Notifications does not support instrumenting from non-main Ractors yet, which is the next blocker for worker-side compile! and render. With non-strict templates freezable, ractorize! now also freezes every file system resolver after eager loading and compiling it, making the template caches shareable for stock applications.
etiennebarrie
force-pushed
the
actionview-frozen-non-strict-templates
branch
from
August 6, 2026 14:48
d4c0aa3 to
455508e
Compare
etiennebarrie
force-pushed
the
actionview-eager-load-templates
branch
from
August 6, 2026 14:48
9414c43 to
297045a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #57, allows using non-strict templates from Ractors (mostly, we need AS::Notifications to be shareable).
While this is not advisable, this helps on the path to view rendering ractor safety without requiring strict-locals templates.