Tokamak icon indicating copy to clipboard operation
Tokamak copied to clipboard

Check if caching reflection data in `MountedElement` improves performance

Open MaxDesiatov opened this issue 3 years ago • 1 comments

typeInfo and property reflection API are one of the most frequently used codepaths in the rendering process. For every element tree update we call those over and over, so I wonder if caching those as attached to MountedElement instances could improve performance in any way. Maybe in addition to each MountedElement having its own cache, which would help in update calls, we could have another dictionary from view types to cached metadata in the reconciler itself. That could also improve performance of mount and first update calls too. We obviously need a proper benchmark and test suite to verify this.

MaxDesiatov avatar Jul 28 '20 09:07 MaxDesiatov

Thanks to the amazing tracing profile demangler by @j-f1 I've got some data here. It makes me think that caching type metadata could lead to some improvements (oh I wish we could just generate this stuff at compile time), typeInfo takes almost half of the time spent on searches in protocol conformance caches:

Screenshot 2020-08-02 at 21 05 33

Will need to gather some profiles from more sophisticated stress tests. As soon as we're able to implement interactive animations, it will be much more noticeable.

MaxDesiatov avatar Aug 02 '20 20:08 MaxDesiatov