New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Separate SyntheticEvent constructors to prevent deopts #19907
Conversation
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 22cd1e5:
|
Details of bundled changes.Comparing: c91c1c4...22cd1e5 react-dom
ReactDOM: size: 🔺+0.4%, gzip: 🔺+0.2% Size changes (experimental) |
Details of bundled changes.Comparing: c91c1c4...22cd1e5 react-dom
ReactDOM: size: 🔺+0.4%, gzip: 🔺+0.1% Size changes (stable) |
Debugging the Flow fix is gonna be fun given Flow is broken for me locally. Sigh. |
* Remove arguments from hot path * Make SyntheticEvent subtypes monomorphic * Maybe fix Flow?
Builds on #19906. (Well, really, replaces it.)
I suspect that I introduced a regression way back in #19433 when I removed the
SyntheticEvent.extend
helper. I'm not 100% sure but I think that as a result of going through differentInterface
s in the same function instance, the singleSyntheticEvent
constructor has become megamorphic (because we'd set different fields in different order onthis
). It is a very hot path (and even more so with the eager change) so I'm splitting these into separate function instances.With this change, I'm consistently seeing ~20% less time spent inside the constructor on average.