Repository navigation
fix: render a fill passed on through components in the running body loop - #522
Merged
Merged
Conversation
A component that passes its slot content on with `<c-fill><c-slot /></c-fill>` used to start a new run of the body renderer for every component in the chain, about 10 Python frames per link, so a chain of about 100 raised RecursionError. The slot now hands a plain template fill to the body renderer that is already running, the way it already hands over its own fallback, through one shared generator that holds the same scopes, runs the same checks and wraps the result the same way as the Slot call it replaces. Any other fill (a Python function, a Slot subclass, a fill from another session, or any fill while code has replaced Slot.__call__ or the template content's methods) still goes through the Slot call. A chain now takes 18 frames at 8 or 64 links without Vue (130 and 690 before); with Vue it grows 2 frames per link up to the fixed cap of the browser-data walk (148 frames at 150 links, which used to raise). Parity snapshots for chains of 1, 3 and 21 links (HTML and Vue, slot hook arguments and replacements, slot data, fallbacks, provides, nested and empty fills, and each error kind) were recorded on the code before the change and pass on both render paths after it. The frame-budget test renders 150-link chains under its budget, and the depth test compares chains of 8 and 64 links. benchmarks/slot_renders.py compares two checkouts on pages of 300 filled, fallback, or passed-on slots. Part of #299. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
Part of #299 (PR A of 2; PR B covers
simple='vue'components nested more than 16 levels deep).What changes
A component that passes its slot content on with
<c-fill><c-slot /></c-fill>used to start a new run of the body renderer for every component in the chain. That cost about 10 Python frames per link, so a chain of about 100 raisedRecursionError.The slot now hands a plain template fill to the body renderer that is already running. It does this through the generator it already uses for its own fallback (
SlotNode._slot_steps), which keeps the same scopes, runs the same checks, and wraps the result the same way as theSlotcall it replaces. Any other fill still goes through theSlotcall: a Python function, aSlotsubclass, a fill from another session, or any fill while code has replacedSlot.__call__or the template content's__call__or_render.Still not fixed: content passed on through an expression. Content passed on as
{{ content }}, wheretemplate_data()returnsslots["default"], or through a Python slot function that calls the fill, still costs about 11 to 12 Python frames per link (11 measured on CPython 3.14.9). Such a chain raisesRecursionErrorsomewhere between 90 and 100 links. The docs page (syntax/index.md) and the changelog entry both say so and give about 80 components as the safe figure.Frames, before and after (CPython 3.14.9, both render paths)
test_render_depth_frameschain, 8 vs 64 links{{ content }}(unchanged)With Vue, a chain grows about 2 frames per link until the walk that collects the browser data reaches its fixed limit of 128 frames. The reviewer confirmed that chains of 1,990 links render, and that 2,100 links stop with the
max_component_deptherror.Tests
test_slot_forwarding_chains.py(new, 132 tests): chains of 1, 3 and 21 links in HTML and Vue. It coverson_slot_renderedarguments and replacements, slot data, fallbacks, provides, nested and empty fills, an expression link, a Python fill at the end, and each error kind with its path and position. The snapshots were recorded one1c370f9e, before the change, and pass on both render paths after it. Every error test also checks that no slot generator is left paused and that both context variables are reset._measurereports aRecursionErroras a result instead of crashing the worker. The new fixtures add about 45 seconds to each render path in the qualification run.test_render_depth_frames.pynow compares chains of 8 and 64 links.main, because the localcitry_corebuild is older than recent Rust merges, so CI is the full proof here. ruff is clean, and mypy is clean with and without--platform linux.Speed gate (2%)
Run on a quiet machine with the other lanes paused. The 1-minute load average stayed between 2.0 and 3.5.
benchmarks/slot_renders.py(new) renders 300 filled, fallback, or passed-on slots per page, alternating base and head in fresh processes:benchmarks/compare.py --size lg, citry rows only, 7 rounds per cell, with head and base interleaved twice. Subsequent render, medians: native on, head 66.8 / 67.6 ms vs base 69.3 / 69.2 ms; native off, head 67.6 / 68.3 ms vs base 69.8 / 67.4 ms. Startup, import, first render and thecitry-constcells are all within 1.5% in both directions.🤖 Generated with Claude Code