Skip to content
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

Remove invokeGuardedCallback from commit phase #21666

Merged
merged 2 commits into from
Jun 14, 2021
Merged

Conversation

gaearon
Copy link
Collaborator

@gaearon gaearon commented Jun 11, 2021

Alternative to #21658.

The reason we have this in the first place is to make "pause on uncaught exceptions" work. That's a development feature. However, the way we do this now, especially after the effect traversal refactor, causes quite a bit of a DEV slowdown in commit phase. This makes it harder to have an accurate sense of how slow a render/commit is. While DEV isn't meant to be representative of real perf, it's bad that commits seem disproportionally expensive because of this. It also legitimately slows down the app in development on its own. So we have a devx fix making devx worse. Which is important? I'd say it's not worth it.

Seb proposed that we just remove this and use the prod path in the commit phase. This PR does that.

Example DEV perf difference

This is on a very shallow tree (1 level deep) but with many host children.

Commit before: 10ms

Screenshot 2021-06-11 at 22 42 24

Commit after: 0.1ms

Screenshot 2021-06-11 at 22 41 49

I expect this to also show up in deeper trees, especially the ones with lots of effects etc.

@facebook-github-bot facebook-github-bot added CLA Signed React Core Team Opened by a member of the React Core Team labels Jun 11, 2021
@sizebot
Copy link

sizebot commented Jun 11, 2021

Comparing: 101ea9f...4556567

Critical size changes

Includes critical production bundles, as well as any change greater than 2%:

Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable/react-dom/cjs/react-dom.production.min.js = 127.08 kB 127.08 kB = 40.74 kB 40.75 kB
oss-experimental/react-dom/cjs/react-dom.production.min.js = 129.89 kB 129.89 kB = 41.67 kB 41.67 kB
facebook-www/ReactDOM-prod.classic.js = 405.00 kB 405.00 kB = 74.93 kB 74.92 kB
facebook-www/ReactDOM-prod.modern.js = 393.35 kB 393.35 kB = 73.11 kB 73.10 kB
facebook-www/ReactDOMForked-prod.classic.js = 405.00 kB 405.00 kB = 74.93 kB 74.93 kB

Significant size changes

Includes any change greater than 0.2%:

Expand to show
Name +/- Base Current +/- gzip Base gzip Current gzip
facebook-www/ReactDOM-dev.classic.js = 1,062.33 kB 1,060.16 kB = 235.47 kB 235.23 kB
facebook-www/ReactDOMForked-dev.classic.js = 1,062.33 kB 1,060.16 kB = 235.47 kB 235.23 kB
oss-stable-semver/react-reconciler/cjs/react-reconciler.development.js = 697.53 kB 696.09 kB = 148.58 kB 148.35 kB
oss-stable/react-reconciler/cjs/react-reconciler.development.js = 697.53 kB 696.09 kB = 148.58 kB 148.35 kB
facebook-www/ReactDOM-dev.modern.js = 1,037.44 kB 1,035.28 kB = 230.46 kB 230.21 kB
facebook-www/ReactDOMForked-dev.modern.js = 1,037.44 kB 1,035.28 kB = 230.45 kB 230.21 kB
oss-experimental/react-art/cjs/react-art.development.js = 660.72 kB 659.28 kB = 143.21 kB 143.04 kB
oss-stable-semver/react-art/cjs/react-art.development.js = 638.25 kB 636.82 kB = 138.45 kB 138.26 kB
oss-stable/react-art/cjs/react-art.development.js = 638.25 kB 636.82 kB = 138.45 kB 138.26 kB
react-native/implementations/ReactNativeRenderer-dev.fb.js = 733.22 kB 731.35 kB = 158.35 kB 158.13 kB
react-native/implementations/ReactFabric-dev.fb.js = 715.46 kB 713.59 kB = 154.00 kB 153.77 kB
facebook-www/ReactART-dev.classic.js = 710.60 kB 708.44 kB = 151.56 kB 151.22 kB
facebook-www/ReactART-dev.modern.js = 700.31 kB 698.14 kB = 149.50 kB 149.15 kB
facebook-www/ReactTestRenderer-dev.modern.js = 635.02 kB 631.59 kB = 136.58 kB 135.87 kB
facebook-www/ReactTestRenderer-dev.classic.js = 635.01 kB 631.58 kB = 136.57 kB 135.86 kB
oss-experimental/react-test-renderer/umd/react-test-renderer.development.js = 657.23 kB 647.80 kB = 139.00 kB 136.32 kB
oss-experimental/react-test-renderer/cjs/react-test-renderer.development.js = 626.57 kB 617.48 kB = 137.44 kB 134.83 kB
oss-stable-semver/react-test-renderer/umd/react-test-renderer.development.js = 640.46 kB 631.03 kB = 135.55 kB 132.88 kB
oss-stable/react-test-renderer/umd/react-test-renderer.development.js = 640.46 kB 631.03 kB = 135.55 kB 132.88 kB
oss-stable-semver/react-test-renderer/cjs/react-test-renderer.development.js = 610.64 kB 601.55 kB = 134.03 kB 131.40 kB
oss-stable/react-test-renderer/cjs/react-test-renderer.development.js = 610.64 kB 601.55 kB = 134.03 kB 131.40 kB
facebook-react-native/react-test-renderer/cjs/ReactTestRenderer-dev.js = 622.35 kB 612.66 kB = 135.16 kB 132.43 kB

Generated by 🚫 dangerJS against 4556567

} catch (error) {
captureCommitPhaseError(fiber, fiber.return, error);
}
setCurrentDebugFiberInDEV(fiber);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: this is OK to call outside DEV.

@gaearon
Copy link
Collaborator Author

gaearon commented Jun 11, 2021

So I tested this in non-synthetic case just to be sure.

Here's results from a real app rendering a (relative small) data table on input change.

Before:

Screenshot 2021-06-12 at 00 46 00

After:

Screenshot 2021-06-12 at 00 37 46

It cut down rendering per keystroke from 1.2s to 300ms, so 4x DEV improvement for a common interaction.

And a 100x absolute improvement. :)

@gaearon gaearon merged commit a8f5e77 into facebook:master Jun 14, 2021
@gaearon gaearon deleted the no-igc branch June 14, 2021 20:45
koto pushed a commit to koto/react that referenced this pull request Jun 15, 2021
* Remove invokeGuardedCallback from commit phase

* Sync fork
eps1lon added a commit to eps1lon/react that referenced this pull request Jun 22, 2021
@eps1lon
Copy link
Collaborator

eps1lon commented Jun 22, 2021

This changed how errors thrown in effects are handled if they were children of an Error Boundary. Previously they were logged to the console and triggered the error overlay in an Error Boundary. With this change the error is no longer logged and triggers no error overlay which is different compared to errors thrown when rendering. #21712 has more context.

facebook-github-bot pushed a commit to facebook/react-native that referenced this pull request Jun 22, 2021
Summary:
This sync includes the following changes:
- **[43f4cc160](facebook/react@43f4cc160 )**: Fix failing test ([#21697](facebook/react#21697)) //<Dan Abramov>//
- **[d0f348dc1](facebook/react@d0f348dc1 )**: Fix for failed Suspense layout semantics ([#21694](facebook/react#21694)) //<Brian Vaughn>//
- **[bd0a96344](facebook/react@bd0a96344 )**: Throw when `act` is used in production ([#21686](facebook/react#21686)) //<Andrew Clark>//
- **[9343f8720](facebook/react@9343f8720 )**: Use the server src files as entry points for the builds/tests ([#21683](facebook/react#21683)) //<Sebastian Markbåge>//
- **[502f8a2a0](facebook/react@502f8a2a0 )**: [Fizz/Flight] Don't use default args ([#21681](facebook/react#21681)) //<Sebastian Markbåge>//
- **[a8f5e77b9](facebook/react@a8f5e77b9 )**: Remove invokeGuardedCallback from commit phase ([#21666](facebook/react#21666)) //<Dan Abramov>//
- **[dbe3363cc](facebook/react@dbe3363cc )**: [Fizz] Implement Legacy renderToString and renderToNodeStream on top of Fizz ([#21276](facebook/react#21276)) //<Sebastian Markbåge>//
- **[101ea9f55](facebook/react@101ea9f55 )**: Set deletedTreeCleanUpLevel to 3 ([#21679](facebook/react#21679)) //<Dan Abramov>//
- **[1a106bdc2](facebook/react@1a106bdc2 )**: Wrap eventhandle-specific logic in a flag ([#21657](facebook/react#21657)) //<Dan Abramov>//
- **[cb30388d1](facebook/react@cb30388d1 )**: Export React Native `AttributeType` Types ([#21661](facebook/react#21661)) //<Timothy Yung>//
- **[c1536795c](facebook/react@c1536795c )**: Revert "Make enableSuspenseLayoutEffectSemantics static for www ([#21617](facebook/react#21617))" ([#21656](facebook/react#21656)) //<Sebastian Markbåge>//

Changelog:
[General][Changed] - React Native sync for revisions c96b78e...568dc35

jest_e2e[run_all_tests]

Reviewed By: rickhanlonii

Differential Revision: D29303157

fbshipit-source-id: 90952885eb2264f4effa04070357b80700bb9be3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed React Core Team Opened by a member of the React Core Team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants