GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [Flight Reply] Encode binary streams as a single collapsed Blob by sebmarkbage · Pull Request #28986 · react/react

Conversation

@sebmarkbage

@sebmarkbage sebmarkbage commented May 3, 2024

Copy link
Copy Markdown
Contributor

Based on #28893.

For other streams we encode each chunk as a separate form field which is a bit bloated. Especially for binary chunks since they also have an indirection. We need some way to encode the chunks as separate anyway. This way the streaming using busboy actually allows each chunk to stream in over the network one at a time.

For binary streams the actual chunking is not important. The chunks can be split and recombined in whatever size chunk makes sense.

Since we buffer the entire content anyway we can combine the chunks to be consecutive. This PR does that with binary streams and also combine them into a single Blob. That way there's no extra overhead when passing through a binary stream.

Ideally, we'd be able to just use the stream from that one Blob but Node.js doesn't return byob streams from Blob. Additionally, we don't actually stream the content of Blobs due to the layering with busboy atm. We could do that for binary streams in particular by replacing the File layering with a stream and resolving each chunk as it comes in. That could be a follow up.

If we stop buffering in the future, this set up still allows us to split them and send other form fields in between while blocked since the protocol is still the same.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@sebmarkbage
sebmarkbage requested a review from gnoff May 3, 2024 18:43
@facebook-github-bot facebook-github-bot added CLA Signed React Core Team Opened by a member of the React Core Team labels May 3, 2024
@react-sizebot

react-sizebot commented May 3, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Comparing: ec9400d...f6b75aa

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.js = 6.66 kB 6.66 kB +0.05% 1.82 kB 1.82 kB
oss-stable/react-dom/cjs/react-dom-client.production.js = 492.61 kB 492.61 kB = 87.88 kB 87.88 kB
oss-experimental/react-dom/cjs/react-dom.production.js = 6.67 kB 6.67 kB +0.11% 1.83 kB 1.83 kB
oss-experimental/react-dom/cjs/react-dom-client.production.js = 498.86 kB 498.86 kB = 88.92 kB 88.93 kB
facebook-www/ReactDOM-prod.classic.js = 591.22 kB 591.22 kB = 103.96 kB 103.96 kB
facebook-www/ReactDOM-prod.modern.js = 567.44 kB 567.44 kB = 100.36 kB 100.36 kB
test_utils/ReactAllWarnings.js Deleted 64.26 kB 0.00 kB Deleted 16.02 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-experimental/react-server-dom-esm/cjs/react-server-dom-esm-client.browser.production.js +1.77% 42.72 kB 43.47 kB +0.70% 8.86 kB 8.92 kB
oss-experimental/react-client/cjs/react-client-flight.production.js +1.76% 45.39 kB 46.19 kB +0.66% 8.80 kB 8.86 kB
oss-experimental/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.browser.production.js +1.70% 44.26 kB 45.01 kB +0.65% 9.23 kB 9.29 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-client.browser.production.js +1.69% 44.59 kB 45.35 kB +0.64% 9.31 kB 9.37 kB
oss-experimental/react-server-dom-esm/cjs/react-server-dom-esm-client.node.production.js +1.60% 47.10 kB 47.86 kB +0.66% 9.89 kB 9.96 kB
oss-experimental/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.node.unbundled.production.js +1.56% 48.35 kB 49.11 kB +0.71% 10.17 kB 10.24 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.unbundled.production.js +1.56% 48.35 kB 49.11 kB +0.73% 10.17 kB 10.25 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.production.js +1.54% 49.03 kB 49.79 kB +0.73% 10.34 kB 10.41 kB
oss-experimental/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.node.production.js +1.54% 49.04 kB 49.80 kB +0.73% 10.32 kB 10.40 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-client.edge.production.js +1.51% 50.07 kB 50.82 kB +0.65% 10.54 kB 10.61 kB
oss-experimental/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.edge.production.js +1.51% 50.08 kB 50.83 kB +0.67% 10.52 kB 10.59 kB
oss-experimental/react-server-dom-esm/esm/react-server-dom-esm-client.browser.production.js +1.23% 69.55 kB 70.40 kB = 15.05 kB 15.01 kB
oss-experimental/react-client/cjs/react-client-flight.development.js +0.99% 86.34 kB 87.19 kB = 19.53 kB 19.50 kB
oss-experimental/react-server-dom-esm/esm/react-server-dom-esm-client.browser.development.js +0.99% 86.35 kB 87.20 kB = 19.24 kB 19.20 kB
oss-experimental/react-server-dom-esm/cjs/react-server-dom-esm-client.browser.development.js +0.98% 86.59 kB 87.44 kB = 19.31 kB 19.27 kB
oss-experimental/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.browser.development.js +0.95% 89.84 kB 90.69 kB = 20.27 kB 20.24 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-client.browser.development.js +0.94% 90.35 kB 91.20 kB = 20.44 kB 20.40 kB
oss-experimental/react-server-dom-esm/cjs/react-server-dom-esm-client.node.development.js +0.90% 94.26 kB 95.12 kB = 21.34 kB 21.30 kB
oss-experimental/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.node.unbundled.development.js +0.89% 96.05 kB 96.90 kB = 21.91 kB 21.87 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.unbundled.development.js +0.89% 96.08 kB 96.93 kB = 21.93 kB 21.90 kB
oss-experimental/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.node.development.js +0.87% 97.48 kB 98.33 kB = 22.28 kB 22.24 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.development.js +0.87% 97.51 kB 98.36 kB = 22.32 kB 22.28 kB
oss-experimental/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.edge.development.js +0.86% 98.55 kB 99.40 kB = 22.48 kB 22.44 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-client.edge.development.js +0.86% 98.58 kB 99.43 kB = 22.52 kB 22.49 kB
test_utils/ReactAllWarnings.js Deleted 64.26 kB 0.00 kB Deleted 16.02 kB 0.00 kB

Generated by 🚫 dangerJS against f6b75aa

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@sebmarkbage
Encode binary streams as a single collapsed Blob
f6b75aa
Since we buffer anyway, we might as well combine the chunks of binary
streams.

Ideally, we'd be able to just use the stream from the Blob but Node.js
doesn't return byob streams from Blob. Additionally, we don't actually
stream the content of Blobs due to the layering with busboy atm. We could
do that for binary streams in particular by replacing the File layering
with a stream.
@sebmarkbage
sebmarkbage force-pushed the replystreams2 branch from 0648eb9 to f6b75aa Compare May 3, 2024 21:24
gnoff
gnoff approved these changes May 6, 2024
View reviewed changes
@sebmarkbage
sebmarkbage merged commit 826bf4e into react:main May 8, 2024
github-actions Bot pushed a commit that referenced this pull request May 8, 2024
@sebmarkbage
[Flight Reply] Encode binary streams as a single collapsed Blob (#28986)
e83564a
Based on #28893.

For other streams we encode each chunk as a separate form field which is
a bit bloated. Especially for binary chunks since they also have an
indirection. We need some way to encode the chunks as separate anyway.
This way the streaming using busboy actually allows each chunk to stream
in over the network one at a time.

For binary streams the actual chunking is not important. The chunks can
be split and recombined in whatever size chunk makes sense.

Since we buffer the entire content anyway we can combine the chunks to
be consecutive. This PR does that with binary streams and also combine
them into a single Blob. That way there's no extra overhead when passing
through a binary stream.

Ideally, we'd be able to just use the stream from that one Blob but
Node.js doesn't return byob streams from Blob. Additionally, we don't
actually stream the content of Blobs due to the layering with busboy
atm. We could do that for binary streams in particular by replacing the
File layering with a stream and resolving each chunk as it comes in.
That could be a follow up.

If we stop buffering in the future, this set up still allows us to split
them and send other form fields in between while blocked since the
protocol is still the same.

DiffTrain build for [826bf4e](826bf4e)
@eps1lon eps1lon mentioned this pull request May 16, 2024
Update React from 4508873393 to 04b058868c vercel/next.js#65864
Merged
eps1lon added a commit to vercel/next.js that referenced this pull request May 16, 2024
@eps1lon
Update React from 4508873393 to 04b058868c (#65864)
c045f0f
Completes #65845 which only
updated Canary not Experimental.

<details>
<summary> React upstream changes</summary>

- react/react#29026
- react/react#29025
- react/react#28743
- react/react#29022
- react/react#29023
- react/react#29015
- react/react#29016
- react/react#28988
- react/react#28987
- react/react#28986
- react/react#29014
- react/react#28982
- react/react#29006
- react/react#28973
- react/react#28841
- react/react#28964
- react/react#28990
- react/react#29003
- react/react#28989
- react/react#28893
- react/react#28887
- react/react#28807
- react/react#28978
- react/react#28963
- react/react#28972
- react/react#28970
- react/react#28816
- react/react#28977
- react/react#28974
- react/react#28976
- react/react#28975
- react/react#28969
- react/react#28966
- react/react#28056

</details>
hanzo-dev pushed a commit to hanzoai/react that referenced this pull request Sep 9, 2026
@sebmarkbage
[Flight Reply] Encode binary streams as a single collapsed Blob (reac…
fd94944
…t#28986)

Based on react#28893.

For other streams we encode each chunk as a separate form field which is
a bit bloated. Especially for binary chunks since they also have an
indirection. We need some way to encode the chunks as separate anyway.
This way the streaming using busboy actually allows each chunk to stream
in over the network one at a time.

For binary streams the actual chunking is not important. The chunks can
be split and recombined in whatever size chunk makes sense.

Since we buffer the entire content anyway we can combine the chunks to
be consecutive. This PR does that with binary streams and also combine
them into a single Blob. That way there's no extra overhead when passing
through a binary stream.

Ideally, we'd be able to just use the stream from that one Blob but
Node.js doesn't return byob streams from Blob. Additionally, we don't
actually stream the content of Blobs due to the layering with busboy
atm. We could do that for binary streams in particular by replacing the
File layering with a stream and resolving each chunk as it comes in.
That could be a follow up.

If we stop buffering in the future, this set up still allows us to split
them and send other form fields in between while blocked since the
protocol is still the same.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@gnoff gnoff gnoff approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

CLA Signed React Core Team Opened by a member of the React Core Team

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@sebmarkbage @react-sizebot @gnoff @facebook-github-bot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.