-
Notifications
You must be signed in to change notification settings - Fork 46.9k
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
Possible regression in dev mode in v16.3 #12502
Comments
Can you turn this into a smaller self-contained example without third party libs? |
I will try to do it but right now I don’t have time, I think doing a setState every 16ms on 20 components in parallel should be sufficient to make it slow. |
Note that if you’re using the StrictMode component, this is expected since it double renders. If you’re not, then it is not expected and probably a bug. |
Here is a fairly simple comparison. Exactly the same code with different react versions:
|
Profile of the example provided by @alshakero Looks like scheduling is somehow off and leaves idle gaps? |
We're spending quite a bit more time in Want to try commenting that line out in the bundle and see if it helps? |
@gaearon yep, this is it. |
Good. I wonder why. Is it the allocation, the enumeration over a fiber, or changing hidden class of the target itself. Can you try to set Object.assign(stashedWorkInProgressProperties, workInProgress); instead and see if it’s still as bad? |
EDIT: Oh, I see what you want to check. Gimme a sec. |
if (true && replayFailedUnitOfWorkWithInvokeGuardedCallback) {
allocStashed();
copyWIP();
}
function allocStashed() {
stashedWorkInProgressProperties = {};
}
function copyWIP() {
Object.assign(stashedWorkInProgressProperties, workInProgress);
} |
Seems like it's still quite a lot. I bet we need to preserve the hidden class and explicitly write out all assignments. |
Hm, maybe it's possible to write a generic function to do that based on type annotations? |
@gaearon an ad hoc confirmation that hidden class is the issue: if (true && replayFailedUnitOfWorkWithInvokeGuardedCallback) {
stashedWorkInProgressProperties = createFiber(
workInProgress.tag,
workInProgress.pendingProps,
workInProgress.key,
workInProgress.mode
);
} |
I forgot to actually copy. if (true && replayFailedUnitOfWorkWithInvokeGuardedCallback) {
stashedWorkInProgressProperties = createFiber(
workInProgress.tag,
workInProgress.pendingProps,
workInProgress.key,
workInProgress.mode
);
Object.assign(stashedWorkInProgressProperties, workInProgress);
} This is still slow, but faster than with |
I tried locally and handwritten version seems pretty fast. |
Tested on the original example and it is much better, thanks! |
Fixed in 16.3.1. |
This example presents a huge performance drop between React 16.2 and React 16.3.
In investigated it and noticed several things:
It is not a big problem for me, but it looks weird, so I decided to share it on Twitter, then @gaearon invited me to submit an issue about it.
The text was updated successfully, but these errors were encountered: