-
Notifications
You must be signed in to change notification settings - Fork 47k
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
Implement event-specific pooling for SyntheticEvent #10237
Implement event-specific pooling for SyntheticEvent #10237
Conversation
Nice! Can you also get it out of |
Yupp! That's the one last thing I have to do, will remove the WIP tag and ping when I get that done 😄 |
neat! What is the benefit of splitting these two out if I might ask. |
@jquense there's some context here: #9325 The goal is to get rid of It does lead to a bit of duplication, but I also think it makes it clearer what's going on. |
084f2f4
to
d9f717d
Compare
We also end up with a slightly smaller build as well, since edit: smaller |
Why? |
I'm not sure, I'll look into it though. |
I wouldn't expect changes in your branch to affect the |
Ah yeah, you're right @gaearon, the current size report is just out of date. With this change the |
Sounds good. Is this still WIP? |
I think it's ready for review! |
@@ -22,6 +21,9 @@ var getEventTarget = require('getEventTarget'); | |||
|
|||
var {HostRoot} = ReactTypeOfWork; | |||
|
|||
var CALLBACK_BOOKKEEPING_POOL_SIZE = 10; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why 10?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was default in the old code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great. 👍
I'm good with this but please verify that pooling works as expected by manual inspection. E.g. make a page listening to mousemove and verify the values are up to date but instances are reused. And that persist() still works. |
I added some event pooling test fixtures: Curious what the best manual test of this is, but I found these two tests helpful when throwing breakpoints in the source. |
Could you please fix conflicts? |
The only module that uses FallbackCompositonState is BeforeInputEventPlugin. The way its structured means there can only be a single instance of FallbackCompositionState at any given time (stored in a local variable at the top-level) so we don't really need pooling here at all. Instead, a single object is now stored in FallbackCompositionState, and access (initializing, reseting, getting data) is gaurded by the exported helper object.
175d201
to
ceee4ca
Compare
@gaearon conflicts resolved 🚀 |
Hmmm. CI still failing. |
This looks good to me. Previously, only Prettier failed so I’m merging it without waiting for CI. (I fixed Prettier). |
Thanks for fixing that @gaearon! |
Thanks for doing this ❤️ |
WIP. I think this is mostly done, still looking at pooling in
TopLevelCallbackBookKeeping
This PR removes
PooledClass
from the synthetic event system in favor of a simpler, event-specific pooling system.getPooled
,release
) to minimize churn in the event system.PooledClass.addPoolingTo
it now uses a helperaddEventPoolingTo
defined in theSyntheticEvent
moduleFallbackCompositionState
. It was only being used in a single event plugin, and the way it's structured makes it so there's only ever a single instance anyway. This means we don't need any sort of pooling. Instead, the composition state is now tracked in a single object which can be initialized and reset.