Conversation
The erase_components mode erases component return types, but keyed rows, boundary children, conditional children, and event callbacks still carry concrete types through their internal rendering paths. These types add compiler work for each distinct view structure and handler. Erase the row views and callbacks used by For and ForEnumerate, the children used by Suspense, Transition, ErrorBoundary, Show, and ShowLet, and the ErrorBoundary fallback callback. Box event callbacks when erase_components is enabled, while avoiding a second box for typed-target handlers. The normal configuration keeps its existing types.
This branch has not been deployed
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.
Summary
ForandForEnumerate.Suspense,Transition, andErrorBoundary, and box theErrorBoundaryfallback callback.ShowandShowLet, and box event callbacks insideonwhenerase_componentsis enabled.on_targetreuses its existing callback box.erase_componentsso the normal configuration retains its existing view and callback types.Motivation
erase_componentserases component return types, but nested views and event callbacks remain concrete. My codebase has about 1 million lines of Rust; a source scan found about 3,200#[component]definitions and 11,200view!calls, including roughly 450 keyed lists, 3,600Show/ShowLetuses, 1,500Suspense/Transitionuses, and 3,200 event attributes. Erasing these internal types aims to shorten my development compile loop. Callback boxing adds allocation and dynamic dispatch; the probe below measures compile time, not runtime cost.Compile time probe
I compiled generated Rust binaries against
leptos_0.9with--cfg erase_componentson both sides. Every binary references all itsview!modules. The keyed and boundary workloads each contain 24 modules with different view and closure types; the varied workload has 24 distinct structures; the combined workload has 72 modules drawn from keyed, boundary, and effect views. The mixed workload has 24 modules with different HTML layouts, each containingShow,ShowLet, and six event handlers. Its baseline already includes theForand boundary changes, whereas the first four rows compare those changes against their original implementations.Each comparison used five alternating trials on rustc 1.100.0-nightly, warm dependencies, development code generation,
CARGO_INCREMENTAL=0, an emptyRUSTC_WRAPPER, and fresh rustc metadata. The figures are median rustc total seconds from-Z time-passes; WebAssembly used thehydratefeature.For,ForEnumerateSuspense,Transition,ErrorBoundaryShow,ShowLet, event callbacksShow,ShowLet, event callbacksMacro expansion was nearly unchanged in the varied workload (0.044 s original, 0.045 s optimized), so that gain came after expansion. The optimized mixed workload was faster in all five paired runs for each target. These local fixtures are not part of the PR, and the figures exclude dependency rebuilds, bundling, and a whole application build.
Verification
cargo fmt --check --package leptos --package tachyspassed.