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

[Flight] Serialize deduped elements by direct reference even if they suspend #28283

Merged
merged 1 commit into from
Feb 8, 2024

Conversation

sebmarkbage
Copy link
Collaborator

@sebmarkbage sebmarkbage commented Feb 8, 2024

In #28123 I switched these to be lazy references. However that creates a lazy wrapper even if they're synchronously available. We try to as much as possible preserve the original data structure in these cases.

E.g. here in the dev outlining I only use a lazy wrapper if it didn't complete synchronously: https://github.com/facebook/react/pull/28272/files#diff-d4c9c509922b3671d3ecce4e051df66dd5c3d38ff913c7a7fe94abc3ba2ed72eR638

Unfortunately we don't have a data structure that tracks the status of each emitted row. We could store the task in the map but then they couldn't be GC:ed as they complete. We could maybe store the status of each element but seems so heavy.

For now I just went back to direct reference which might be an issue since it can suspend something higher up when deduped.

@sebmarkbage sebmarkbage requested a review from gnoff February 8, 2024 23:31
@facebook-github-bot facebook-github-bot added CLA Signed React Core Team Opened by a member of the React Core Team labels Feb 8, 2024
@react-sizebot
Copy link

Comparing: d3def47...631bb04

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 = 176.64 kB 176.64 kB = 55.02 kB 55.02 kB
oss-experimental/react-dom/cjs/react-dom.production.min.js = 178.63 kB 178.63 kB = 55.59 kB 55.59 kB
facebook-www/ReactDOM-prod.classic.js = 591.73 kB 591.73 kB = 104.44 kB 104.44 kB
facebook-www/ReactDOM-prod.modern.js = 575.51 kB 575.51 kB = 101.53 kB 101.53 kB
test_utils/ReactAllWarnings.js Deleted 67.02 kB 0.00 kB Deleted 16.42 kB 0.00 kB

Significant size changes

Includes any change greater than 0.2%:

Expand to show
Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable-semver/react-server/cjs/react-server-flight.production.js +0.68% 56.77 kB 57.15 kB +0.94% 13.89 kB 14.02 kB
oss-stable/react-server/cjs/react-server-flight.production.js +0.68% 56.77 kB 57.15 kB +0.94% 13.89 kB 14.02 kB
oss-experimental/react-server/cjs/react-server-flight.production.js +0.58% 66.44 kB 66.83 kB +0.69% 15.88 kB 15.99 kB
oss-stable-semver/react-server/cjs/react-server-flight.development.js +0.58% 66.51 kB 66.90 kB +0.68% 16.20 kB 16.31 kB
oss-stable/react-server/cjs/react-server-flight.development.js +0.58% 66.51 kB 66.90 kB +0.68% 16.20 kB 16.31 kB
oss-experimental/react-server/cjs/react-server-flight.development.js +0.50% 76.21 kB 76.60 kB +0.63% 18.18 kB 18.29 kB
facebook-www/ReactFlightDOMServer-dev.modern.js +0.46% 84.42 kB 84.81 kB +0.64% 18.25 kB 18.36 kB
oss-stable-semver/react-server-dom-esm/cjs/react-server-dom-esm-server.node.production.js +0.43% 90.17 kB 90.56 kB +0.43% 21.45 kB 21.54 kB
oss-stable/react-server-dom-esm/cjs/react-server-dom-esm-server.node.production.js +0.43% 90.17 kB 90.56 kB +0.43% 21.45 kB 21.54 kB
oss-stable-semver/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.browser.production.js +0.42% 92.24 kB 92.62 kB +0.55% 22.24 kB 22.37 kB
oss-stable/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.browser.production.js +0.42% 92.24 kB 92.62 kB +0.55% 22.24 kB 22.37 kB
oss-stable-semver/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.edge.production.js +0.41% 92.90 kB 93.28 kB +0.41% 22.48 kB 22.57 kB
oss-stable/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.edge.production.js +0.41% 92.90 kB 93.28 kB +0.41% 22.48 kB 22.57 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-server.browser.production.js +0.40% 94.82 kB 95.21 kB +0.55% 22.97 kB 23.09 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-server.browser.production.js +0.40% 94.82 kB 95.21 kB +0.55% 22.97 kB 23.09 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-server.edge.production.js +0.40% 94.96 kB 95.34 kB +0.39% 23.04 kB 23.13 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-server.edge.production.js +0.40% 94.96 kB 95.34 kB +0.39% 23.04 kB 23.13 kB
oss-stable-semver/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.node.unbundled.production.js +0.40% 95.57 kB 95.96 kB +0.40% 22.67 kB 22.76 kB
oss-stable/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.node.unbundled.production.js +0.40% 95.57 kB 95.96 kB +0.40% 22.67 kB 22.76 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.unbundled.production.js +0.39% 97.99 kB 98.37 kB +0.40% 23.28 kB 23.37 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.unbundled.production.js +0.39% 97.99 kB 98.37 kB +0.40% 23.28 kB 23.37 kB
oss-stable-semver/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.node.production.js +0.39% 98.24 kB 98.62 kB +0.39% 23.50 kB 23.60 kB
oss-stable/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.node.production.js +0.39% 98.24 kB 98.62 kB +0.39% 23.50 kB 23.60 kB
oss-experimental/react-server-dom-esm/cjs/react-server-dom-esm-server.node.production.js +0.38% 100.08 kB 100.46 kB +0.39% 23.50 kB 23.59 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.production.js +0.38% 100.65 kB 101.03 kB +0.37% 24.17 kB 24.26 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.production.js +0.38% 100.65 kB 101.03 kB +0.37% 24.17 kB 24.26 kB
oss-stable-semver/react-server-dom-esm/cjs/react-server-dom-esm-server.node.development.js +0.38% 100.68 kB 101.06 kB +0.40% 23.99 kB 24.09 kB
oss-stable/react-server-dom-esm/cjs/react-server-dom-esm-server.node.development.js +0.38% 100.68 kB 101.06 kB +0.40% 23.99 kB 24.09 kB
oss-experimental/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.browser.production.js +0.37% 102.59 kB 102.97 kB +0.39% 24.49 kB 24.58 kB
oss-stable-semver/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.browser.development.js +0.37% 102.95 kB 103.34 kB +0.40% 24.83 kB 24.93 kB
oss-stable/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.browser.development.js +0.37% 102.95 kB 103.34 kB +0.40% 24.83 kB 24.93 kB
oss-experimental/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.edge.production.js +0.37% 103.25 kB 103.63 kB +0.39% 24.70 kB 24.79 kB
oss-stable-semver/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.edge.development.js +0.37% 103.66 kB 104.04 kB +0.38% 25.02 kB 25.12 kB
oss-stable/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.edge.development.js +0.37% 103.66 kB 104.04 kB +0.38% 25.02 kB 25.12 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-server.browser.production.js +0.37% 105.17 kB 105.56 kB +0.38% 25.22 kB 25.32 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-server.edge.production.js +0.36% 105.31 kB 105.69 kB +0.38% 25.26 kB 25.36 kB
oss-experimental/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.node.unbundled.production.js +0.36% 105.48 kB 105.86 kB +0.38% 24.71 kB 24.81 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-server.browser.development.js +0.36% 105.54 kB 105.92 kB +0.37% 25.55 kB 25.64 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-server.browser.development.js +0.36% 105.54 kB 105.92 kB +0.37% 25.55 kB 25.64 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-server.edge.development.js +0.36% 105.72 kB 106.11 kB +0.36% 25.58 kB 25.67 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-server.edge.development.js +0.36% 105.72 kB 106.11 kB +0.36% 25.58 kB 25.67 kB
oss-stable-semver/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.node.unbundled.development.js +0.36% 106.09 kB 106.48 kB +0.39% 25.20 kB 25.30 kB
oss-stable/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.node.unbundled.development.js +0.36% 106.09 kB 106.48 kB +0.39% 25.20 kB 25.30 kB
oss-stable-semver/react-server-dom-turbopack/umd/react-server-dom-turbopack-server.browser.development.js +0.36% 108.73 kB 109.12 kB +0.39% 25.12 kB 25.22 kB
oss-stable/react-server-dom-turbopack/umd/react-server-dom-turbopack-server.browser.development.js +0.36% 108.73 kB 109.12 kB +0.39% 25.12 kB 25.22 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.unbundled.production.js +0.36% 107.89 kB 108.27 kB +0.38% 25.32 kB 25.42 kB
oss-experimental/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.node.production.js +0.36% 108.14 kB 108.52 kB +0.39% 25.54 kB 25.64 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.unbundled.development.js +0.35% 108.52 kB 108.90 kB +0.37% 25.81 kB 25.91 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.unbundled.development.js +0.35% 108.52 kB 108.90 kB +0.37% 25.81 kB 25.91 kB
oss-stable-semver/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.node.development.js +0.35% 108.73 kB 109.12 kB +0.36% 26.03 kB 26.12 kB
oss-stable/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.node.development.js +0.35% 108.73 kB 109.12 kB +0.36% 26.03 kB 26.12 kB
oss-stable-semver/react-server-dom-webpack/umd/react-server-dom-webpack-server.browser.development.js +0.35% 111.45 kB 111.84 kB +0.38% 25.86 kB 25.95 kB
oss-stable/react-server-dom-webpack/umd/react-server-dom-webpack-server.browser.development.js +0.35% 111.45 kB 111.84 kB +0.38% 25.86 kB 25.95 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.production.js +0.35% 110.55 kB 110.93 kB +0.37% 26.22 kB 26.32 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.development.js +0.35% 111.15 kB 111.54 kB +0.37% 26.68 kB 26.78 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.development.js +0.35% 111.15 kB 111.54 kB +0.37% 26.68 kB 26.78 kB
oss-experimental/react-server-dom-esm/cjs/react-server-dom-esm-server.node.development.js +0.35% 111.26 kB 111.64 kB +0.38% 26.28 kB 26.38 kB
oss-experimental/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.browser.development.js +0.34% 113.33 kB 113.72 kB +0.37% 27.06 kB 27.16 kB
oss-experimental/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.edge.development.js +0.33% 114.71 kB 115.09 kB +0.37% 27.49 kB 27.59 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-server.browser.development.js +0.33% 115.91 kB 116.30 kB +0.36% 27.79 kB 27.89 kB
oss-experimental/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.node.unbundled.development.js +0.33% 116.67 kB 117.05 kB +0.37% 27.49 kB 27.59 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-server.edge.development.js +0.33% 116.77 kB 117.16 kB +0.36% 28.05 kB 28.15 kB
oss-experimental/react-server-dom-turbopack/umd/react-server-dom-turbopack-server.browser.development.js +0.33% 119.56 kB 119.95 kB +0.39% 27.42 kB 27.53 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.unbundled.development.js +0.32% 119.09 kB 119.48 kB +0.37% 28.11 kB 28.21 kB
oss-experimental/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.node.development.js +0.32% 119.31 kB 119.69 kB +0.35% 28.32 kB 28.42 kB
oss-experimental/react-server-dom-webpack/umd/react-server-dom-webpack-server.browser.development.js +0.32% 122.29 kB 122.68 kB +0.38% 28.14 kB 28.25 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.development.js +0.32% 121.73 kB 122.11 kB +0.36% 28.99 kB 29.10 kB
test_utils/ReactAllWarnings.js Deleted 67.02 kB 0.00 kB Deleted 16.42 kB 0.00 kB

Generated by 🚫 dangerJS against 631bb04

Copy link
Collaborator

@gnoff gnoff left a comment

Choose a reason for hiding this comment

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

I'm wondering if this will reintroduce the other bug that was fixed when you introduced key support. We got into a weird state where the root chunk never resolved to a value and always fullfilled with null. Maybe the other change where the model root condition is checked first is what resolved that though

@sebmarkbage
Copy link
Collaborator Author

Yes. Either the lazy or the modelRoot thing should fix that issue so we have at least the other fix.

@sebmarkbage sebmarkbage merged commit ba5e6a8 into facebook:main Feb 8, 2024
36 checks passed
github-actions bot pushed a commit that referenced this pull request Feb 8, 2024
…suspend (#28283)

In #28123 I switched these to be lazy references. However that creates a
lazy wrapper even if they're synchronously available. We try to as much
as possible preserve the original data structure in these cases.

E.g. here in the dev outlining I only use a lazy wrapper if it didn't
complete synchronously:
https://github.com/facebook/react/pull/28272/files#diff-d4c9c509922b3671d3ecce4e051df66dd5c3d38ff913c7a7fe94abc3ba2ed72eR638

Unfortunately we don't have a data structure that tracks the status of
each emitted row. We could store the task in the map but then they
couldn't be GC:ed as they complete. We could maybe store the status of
each element but seems so heavy.

For now I just went back to direct reference which might be an issue
since it can suspend something higher up when deduped.

DiffTrain build for [ba5e6a8](ba5e6a8)
unstubbable added a commit to unstubbable/react that referenced this pull request Mar 21, 2024
EdisonVan pushed a commit to EdisonVan/react that referenced this pull request Apr 15, 2024
…suspend (facebook#28283)

In facebook#28123 I switched these to be lazy references. However that creates a
lazy wrapper even if they're synchronously available. We try to as much
as possible preserve the original data structure in these cases.

E.g. here in the dev outlining I only use a lazy wrapper if it didn't
complete synchronously:
https://github.com/facebook/react/pull/28272/files#diff-d4c9c509922b3671d3ecce4e051df66dd5c3d38ff913c7a7fe94abc3ba2ed72eR638

Unfortunately we don't have a data structure that tracks the status of
each emitted row. We could store the task in the map but then they
couldn't be GC:ed as they complete. We could maybe store the status of
each element but seems so heavy.

For now I just went back to direct reference which might be an issue
since it can suspend something higher up when deduped.
bigfootjon pushed a commit that referenced this pull request Apr 18, 2024
…suspend (#28283)

In #28123 I switched these to be lazy references. However that creates a
lazy wrapper even if they're synchronously available. We try to as much
as possible preserve the original data structure in these cases.

E.g. here in the dev outlining I only use a lazy wrapper if it didn't
complete synchronously:
https://github.com/facebook/react/pull/28272/files#diff-d4c9c509922b3671d3ecce4e051df66dd5c3d38ff913c7a7fe94abc3ba2ed72eR638

Unfortunately we don't have a data structure that tracks the status of
each emitted row. We could store the task in the map but then they
couldn't be GC:ed as they complete. We could maybe store the status of
each element but seems so heavy.

For now I just went back to direct reference which might be an issue
since it can suspend something higher up when deduped.

DiffTrain build for commit ba5e6a8.
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.

4 participants