Skip to content

[Perf] Fine-grained reactivity #3624

Open
@nolanlawson

Description

@nolanlawson

Update: tracking progress on this as separate issues/PRs:


In the js-framework-benchmark, our slowest area is currently "select row":

Screenshot 2023-07-31 at 8 20 50 AM

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:

  1. Implement an equivalent to Vue's v-memo; this is how they're able to get a high score on this benchmark.
  2. 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".)
  3. 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 like lwc:each (Allow shorthand for directives like lwc:ref #3303).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions