perf(Button/Select/SelectMenu/InputMenu): narrow reactive dependencies#6736
Open
benjamincanac wants to merge 4 commits into
Open
perf(Button/Select/SelectMenu/InputMenu): narrow reactive dependencies#6736benjamincanac wants to merge 4 commits into
benjamincanac wants to merge 4 commits into
Conversation
3 tasks
Contributor
📝 WalkthroughWalkthroughRuntime components now narrow reactive inputs passed to Estimated code review effort: 3 (Moderate) | ~20 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
commit: |
3 tasks
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.
🔗 Linked issue
Related to #6293 and #4154
❓ Type of change
📚 Description
Profiling a Button re-render showed that most of its cost came from over-broad reactivity, not from rendering itself.
ButtonfeduseComponentIconsa{ ...props }spread, which walks every prop through theuseComponentPropsproxy (with its camelCase/kebabCase checks per key) and subscribes the icons computed, and throughisLeading/isTrailingtheuicomputed, to every single prop. Any prop change, evenclass, re-ran the whole tv pipeline.Select,SelectMenuandInputMenuhad the same issue throughdefu(props, ...), which also copies every prop. Button additionally re-ranomit(linkProps, ...)in the template on every render, walking ~25 forwarded link keys through three proxy layers.This narrows the icons input to the props the composable actually reads (an explicit
!== undefinedcheck keepstrailingIcon: nullbehaving exactly likedefudid) and memoizes Button's forwarded link props in a computed.Also adds two benchmarks: a Button link vs no-link comparison and a layer decomposition of the Button stack (plain button → reka
Primitive→ULinkBase→ULink→UButton), which is how this was found — the Link/LinkBase layers turned out to be ~2% of self-time, while Button's own reactivity accounted for most of the rest.Measured with the new benches: Button re-render goes from 2,574 to 4,103 ops/s (388µs → 244µs per toggle cycle). Output classes are byte-identical: full suite passes with zero snapshot changes.
This should noticeably help cases like the #6293 editor toolbar (25 buttons re-rendering per transaction), though that issue likely also needs re-render reduction in the toolbar itself.
📝 Checklist