Tokamak
Tokamak copied to clipboard
Check if caching reflection data in `MountedElement` improves performance
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.
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](https://user-images.githubusercontent.com/112310/89131373-2c6abe80-d504-11ea-9915-d1c666c1e1e4.png)
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.