-
Notifications
You must be signed in to change notification settings - Fork 48.8k
Remove firstEffect from Persistent Mode Optimization #19381
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
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 dec061d:
|
I'm trying to remember the reason why We already do something similar for the
I'm thinking maybe the original reason has something to do with resuming? Maybe it's not relevant anymore? If so, maybe we could get rid of |
I was hoping to do something like this anyway to get rid of this Offscreen check that's currently sitting smack dab in the middle of the hot path: react/packages/react-reconciler/src/ReactFiberWorkLoop.new.js Lines 1769 to 1777 in fed4ae0
|
Lol next time I'll read the description before I comment:
Yeah this makes sense to me. Let's do it. |
👍 This sounds like a good change. Who owns it? Want me to pick it up? |
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.
Makes sense. Will be nicer once we can just check the subtreeTag
directly.
Accumulating the effectTag as we go is effectively what the effect list did. However that has some downsides too. It makes rendering something only to throw it out difficult. It also makes things order dependent. Interestingly I think the new refactor will “fix” the suspense list issue by making effects fire in first-to-last child order instead of the reveal order as was before. appendAllChildren is another one of those that would be nice to move to happen inside the children and append to the parent but it suffers from the same problem. Moving it to the complete phase as a second pass should work though. It also allows passes to ignore it if it knows it doesn’t have to like if something is Offscreen. However it also requires us to remember to call it. |
Yeah the key difference between the effect list and |
What is the suspense list issue you all are referring to? |
@lunaruan SuspenseList with |
Persistent mode needs to clone a parent and add its children if a child has changed. We have an optimization in persistent mode where we don't do that if no child could've changed. If there are no effects scheduled for any child then there couldn't have been changes. Instead of checking for this on firstEffect, we now check this on the children's effectTag and subtreeTags. This is quite unfortunate because if we could just do this check a little bit later we would've already gotten it transferred to the completed work's subtreeTag. Now we have to loop over all the children and if any of them changed, we have to loop over them again. Doing at least two loops per parent.
e829f13
to
dec061d
Compare
Builds on top of #19322 with one commit e829f13
Persistent mode needs to clone a parent and add its children if a child has changed.
We have an optimization in persistent mode where we don't do that if no child could've changed. If there are no effects scheduled for any child then there couldn't have been changes.
Instead of checking for this on firstEffect, we now check this on the children's effectTag and subtreeTags.
This is quite unfortunate because if we could just do this check a little bit later we would've already gotten it transferred to the completed work's subtreeTag. Now we have to loop over all the children and if any of them changed, we have to loop over them again. Doing at least two loops per parent.
One possible fix to this would be to move the resetChildLanes to be an explicit call within each completeWork branch before they return. That way we could call it before returning in this case.