Open
Description
Update: tracking progress on this as separate issues/PRs:
- Apply static vnode optimization to elements with event listeners #3518
- perf: apply static optimization to lwc:ref #3550
- perf(engine-core): implement static parts #3694
- [Perf] Avoid calling
traverseAndSetElements
on every re-render #3800 - Apply static parts optimization to dynamic attributes (non-
class
/style
) - Apply static parts optimization to dynamic
style
- Apply static parts optimization to dynamic
class
- Apply static parts optimization to dynamic text content
- Expand static content optimization to light DOM slots (stretch goal)
- Implement fine-grained reactivity for iterators (i.e.
createRenderEffect
ala SolidJS)
In the js-framework-benchmark
, our slowest area is currently "select row":
The main thing about this test is that it's rendering 10k rows and then only updating every 10th one. So we are generating 9k VDOM nodes that never change and then uselessly diffing them.
The static content optimization helps a bit (krausest/js-framework-benchmark#1288), but it's not perfect because we still have the key
which is different for every row, so not every VDOM can be static-optimized.
I can think of a few ways to optimize this:
- Implement an equivalent to Vue's
v-memo
; this is how they're able to get a high score on this benchmark. - Implement something like fine-grained reactivity or block virtual DOM (Could "block virtual dom" benefit LWC? #3565) to only re-render the parts of the iterator that actual change based on the reactive observers. (This can be thought of as a kind of "auto memo".)
- Hoist the
key
outside of the vdom inside of the loop somehow – this would allow the underlying vdom to be more likely to be statically-optimized. (It would help with this benchmark, but maybe not with more dynamic iterator content.) We could also make this part of building a replacement iterator directive likelwc:each
(Allow shorthand for directives likelwc:ref
#3303).
Activity