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

Track Event Time as the Start Time for Suspense #15358

Merged
merged 6 commits into from
Apr 10, 2019

Conversation

sebmarkbage
Copy link
Collaborator

The new suspense model is based on the last "event time" that influenced the suspended render.

The "event time" is the time of the "update" (root render, setState, dispatch) - which we infer from its expiration time.

If this is a "retry", then there is no "update" and the event time is the time we committed the fallback. This event time is only accounted for if we actually switch from fallback to content, i.e. make progress. If we retry and don't make further progress, then this event time isn't accounted for.

To make the math simple and fast, I model the committed time as an "normal pri expiration time" at the time it committed.

Since there can be multiple updates and retries in the same batch, we use the most recent time for our heuristic. That ensures that we at least never wait longer than we otherwise would've.

Since we can't tell the difference between committed and suspended updates, this PR will error on the side of including committed updates.

For now, I still use the hard coded 150ms suspense time starting from the event time. In a follow up, I'll add the Just Noticeable Difference heuristic instead.

@sizebot
Copy link

sizebot commented Apr 9, 2019

ReactDOM: size: -0.2%, gzip: -0.3%

Details of bundled changes.

Comparing: 875d05d...b65f6a4

react-dom

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-dom.development.js -0.1% -0.0% 894.19 KB 892.95 KB 201.97 KB 201.87 KB UMD_DEV
react-dom.production.min.js -0.2% -0.3% 105.6 KB 105.4 KB 34.21 KB 34.1 KB UMD_PROD
react-dom.profiling.min.js -0.2% -0.3% 108.61 KB 108.41 KB 34.8 KB 34.71 KB UMD_PROFILING
react-dom.development.js -0.1% -0.0% 888.82 KB 887.58 KB 200.41 KB 200.31 KB NODE_DEV
react-dom.production.min.js -0.2% -0.2% 105.6 KB 105.39 KB 33.65 KB 33.59 KB NODE_PROD
react-dom.profiling.min.js -0.2% -0.2% 108.71 KB 108.51 KB 34.23 KB 34.15 KB NODE_PROFILING
ReactDOM-dev.js -0.2% -0.1% 914.91 KB 913.52 KB 202.22 KB 202.07 KB FB_WWW_DEV
ReactDOM-prod.js -0.3% -0.3% 338.3 KB 337.38 KB 62.29 KB 62.08 KB FB_WWW_PROD
ReactDOM-profiling.js -0.1% -0.3% 344.97 KB 344.46 KB 63.69 KB 63.52 KB FB_WWW_PROFILING
react-dom-unstable-fire.development.js -0.1% -0.0% 894.52 KB 893.27 KB 202.11 KB 202.01 KB UMD_DEV
react-dom-unstable-fire.production.min.js -0.2% -0.3% 105.61 KB 105.42 KB 34.21 KB 34.11 KB UMD_PROD
react-dom-unstable-fire.profiling.min.js -0.2% -0.3% 108.62 KB 108.42 KB 34.81 KB 34.72 KB UMD_PROFILING
react-dom-unstable-fire.development.js -0.1% -0.0% 889.14 KB 887.9 KB 200.54 KB 200.45 KB NODE_DEV
react-dom-unstable-fire.production.min.js -0.2% -0.2% 105.61 KB 105.41 KB 33.66 KB 33.6 KB NODE_PROD
react-dom-unstable-fire.profiling.min.js -0.2% -0.2% 108.73 KB 108.53 KB 34.24 KB 34.16 KB NODE_PROFILING
ReactFire-dev.js -0.2% -0.1% 914.1 KB 912.71 KB 202.26 KB 202.11 KB FB_WWW_DEV
ReactFire-prod.js -0.3% -0.4% 326.96 KB 326.04 KB 59.99 KB 59.77 KB FB_WWW_PROD
ReactFire-profiling.js -0.2% -0.3% 333.57 KB 333.07 KB 61.36 KB 61.16 KB FB_WWW_PROFILING
react-dom-unstable-new-scheduler.development.js -0.1% -0.0% 887.32 KB 886.08 KB 199.83 KB 199.73 KB NODE_DEV
react-dom-unstable-new-scheduler.production.min.js -0.1% -0.2% 103.67 KB 103.57 KB 33.13 KB 33.08 KB NODE_PROD
react-dom-unstable-new-scheduler.profiling.min.js -0.1% -0.2% 107.02 KB 106.91 KB 34.02 KB 33.96 KB NODE_PROFILING
ReactDOMNewScheduler-dev.js -0.2% -0.1% 914.94 KB 913.55 KB 202.22 KB 202.07 KB FB_WWW_DEV
ReactDOMNewScheduler-prod.js -0.0% -0.1% 332.28 KB 332.16 KB 61.82 KB 61.74 KB FB_WWW_PROD
ReactDOMNewScheduler-profiling.js -0.1% -0.1% 337.72 KB 337.42 KB 62.82 KB 62.76 KB FB_WWW_PROFILING
react-dom-unstable-native-dependencies.development.js 0.0% -0.0% 60.76 KB 60.76 KB 15.85 KB 15.85 KB UMD_DEV
react-dom-unstable-native-dependencies.production.min.js 0.0% 0.0% 10.69 KB 10.69 KB 3.67 KB 3.67 KB UMD_PROD
react-dom-unstable-native-dependencies.development.js 0.0% -0.0% 60.43 KB 60.43 KB 15.72 KB 15.72 KB NODE_DEV
react-dom-server.browser.development.js 0.0% 0.0% 136.52 KB 136.52 KB 35.92 KB 35.92 KB UMD_DEV
react-dom-server.browser.production.min.js 0.0% -0.0% 19.24 KB 19.24 KB 7.24 KB 7.24 KB UMD_PROD
react-dom-server.browser.development.js 0.0% 0.0% 132.65 KB 132.65 KB 34.98 KB 34.99 KB NODE_DEV
ReactDOMServer-dev.js 0.0% -0.0% 135.04 KB 135.04 KB 34.69 KB 34.69 KB FB_WWW_DEV
react-dom-server.node.development.js 0.0% 0.0% 134.59 KB 134.59 KB 35.53 KB 35.53 KB NODE_DEV
react-dom-unstable-fizz.browser.production.min.js 0.0% -0.1% 1.21 KB 1.21 KB 707 B 706 B UMD_PROD
react-dom-unstable-fizz.browser.development.js 0.0% +0.1% 3.49 KB 3.49 KB 1.41 KB 1.41 KB NODE_DEV
react-dom-unstable-fizz.node.production.min.js 0.0% -0.1% 1.1 KB 1.1 KB 668 B 667 B NODE_PROD

react-art

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-art.development.js -0.2% -0.1% 639.96 KB 638.72 KB 138.16 KB 138.04 KB UMD_DEV
react-art.production.min.js -0.2% -0.3% 97.32 KB 97.1 KB 29.78 KB 29.68 KB UMD_PROD
react-art.development.js -0.2% -0.1% 571.17 KB 569.93 KB 120.87 KB 120.76 KB NODE_DEV
react-art.production.min.js -0.3% -0.6% 62.34 KB 62.13 KB 19.05 KB 18.94 KB NODE_PROD
ReactART-dev.js -0.2% -0.1% 582.23 KB 580.84 KB 120.55 KB 120.39 KB FB_WWW_DEV
ReactART-prod.js -0.5% -0.8% 198.97 KB 197.88 KB 33.78 KB 33.52 KB FB_WWW_PROD

react-native-renderer

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
ReactNativeRenderer-dev.js -0.2% -0.1% 715.8 KB 714.4 KB 151.26 KB 151.15 KB RN_FB_DEV
ReactNativeRenderer-prod.js -0.6% -0.7% 250.08 KB 248.51 KB 43.31 KB 43.01 KB RN_FB_PROD
ReactNativeRenderer-profiling.js -0.4% -0.6% 256.12 KB 255.07 KB 44.65 KB 44.38 KB RN_FB_PROFILING
ReactNativeRenderer-dev.js -0.2% -0.1% 715.71 KB 714.32 KB 151.23 KB 151.12 KB RN_OSS_DEV
ReactNativeRenderer-prod.js -0.6% -0.7% 250.09 KB 248.53 KB 43.3 KB 43.01 KB RN_OSS_PROD
ReactNativeRenderer-profiling.js -0.4% -0.6% 256.13 KB 255.09 KB 44.64 KB 44.38 KB RN_OSS_PROFILING
ReactFabric-dev.js -0.2% -0.1% 704.49 KB 703.1 KB 148.58 KB 148.45 KB RN_FB_DEV
ReactFabric-prod.js -0.6% -0.7% 243.36 KB 241.83 KB 42.01 KB 41.7 KB RN_FB_PROD
ReactFabric-profiling.js -0.4% -0.7% 248.75 KB 247.74 KB 43.34 KB 43.04 KB RN_FB_PROFILING
ReactFabric-dev.js -0.2% -0.1% 704.4 KB 703.01 KB 148.53 KB 148.41 KB RN_OSS_DEV
ReactFabric-prod.js -0.6% -0.7% 243.37 KB 241.83 KB 42.01 KB 41.69 KB RN_OSS_PROD
ReactFabric-profiling.js -0.4% -0.7% 248.76 KB 247.75 KB 43.33 KB 43.04 KB RN_OSS_PROFILING

react-test-renderer

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-test-renderer.development.js -0.2% 0.0% 585.7 KB 584.46 KB 123.97 KB 123.99 KB UMD_DEV
react-test-renderer.production.min.js -0.4% -0.4% 63.65 KB 63.42 KB 19.47 KB 19.4 KB UMD_PROD
react-test-renderer.development.js -0.2% 0.0% 581.33 KB 580.08 KB 122.83 KB 122.84 KB NODE_DEV
react-test-renderer.production.min.js -0.3% -0.4% 63.35 KB 63.14 KB 19.28 KB 19.2 KB NODE_PROD
ReactTestRenderer-dev.js -0.2% -0.1% 593.93 KB 592.54 KB 123.17 KB 123.01 KB FB_WWW_DEV

react-reconciler

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-reconciler.development.js -0.2% -0.1% 574.35 KB 573.11 KB 120.41 KB 120.31 KB NODE_DEV
react-reconciler.production.min.js -0.3% -0.3% 63.34 KB 63.14 KB 18.83 KB 18.77 KB NODE_PROD
react-reconciler-persistent.development.js -0.2% -0.1% 572.16 KB 570.91 KB 119.51 KB 119.41 KB NODE_DEV
react-reconciler-persistent.production.min.js -0.3% -0.3% 63.35 KB 63.15 KB 18.84 KB 18.77 KB NODE_PROD
react-reconciler-reflection.production.min.js 0.0% -0.1% 2.43 KB 2.43 KB 1.09 KB 1.09 KB NODE_PROD

Generated by 🚫 dangerJS

When we switch back from fallback to content, we made progress and we track
the time from when we showed the fallback in the first place as the
last time we made progress.
This ensures that we don't resuspend unnecessarily if we're just retrying
the same exact boundary again. We can still unnecessarily suspend
for nested boundaries.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants