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] Stack Parallel Components in Separate Tracks #31735

Merged
merged 1 commit into from
Dec 16, 2024

Conversation

sebmarkbage
Copy link
Collaborator

@sebmarkbage sebmarkbage commented Dec 11, 2024

Stacked on #31729

Screenshot 2024-12-11 at 3 36 41 PM

The Server Components visualization is currently a tree flame graph where parent spans the child. This makes it equivalent to the Client Components visualization.

However, since Server Components can be async and therefore parallel, we need to do something when two children are executed in parallel. This PR bumps parallel children into a separate track and then within that track if that child has more children it can grow within that track.

I currently just cut off more than 10 parallel tracks.

Synchronous Server Components are still in sequence but it's unlikely because even a simple microtasky Async Component is still parallel.

Screenshot 2024-12-11 at 4 31 17 PM

I think this is probably not a very useful visualization for Server Components but we can try it out.

I'm also going to try a different visualization where parent-child relationship is horizontal and parallel vertical instead, but it might not be possible to make that line up in this tool. It makes it a little harder to see how much different components (including their children) impact the overall tree. If that's the only visualization it's also confusing why it's different dimensions than the Client Component version.

Copy link

vercel bot commented Dec 11, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-compiler-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 12, 2024 7:07pm

@react-sizebot
Copy link

react-sizebot commented Dec 11, 2024

Comparing: 6928bf2...81afa05

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.68 kB 6.68 kB = 1.82 kB 1.82 kB
oss-stable/react-dom/cjs/react-dom-client.production.js = 510.76 kB 510.76 kB = 91.41 kB 91.41 kB
oss-experimental/react-dom/cjs/react-dom.production.js = 6.69 kB 6.69 kB = 1.83 kB 1.83 kB
oss-experimental/react-dom/cjs/react-dom-client.production.js = 515.69 kB 515.69 kB = 92.12 kB 92.12 kB
facebook-www/ReactDOM-prod.classic.js = 595.61 kB 595.61 kB = 105.12 kB 105.12 kB
facebook-www/ReactDOM-prod.modern.js = 585.88 kB 585.88 kB = 103.55 kB 103.55 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-parcel/cjs/react-server-dom-parcel-client.browser.development.js +1.42% 98.40 kB 99.80 kB +1.49% 18.53 kB 18.80 kB
oss-experimental/react-server-dom-esm/cjs/react-server-dom-esm-client.browser.development.js +1.41% 99.28 kB 100.67 kB +1.45% 18.97 kB 19.24 kB
oss-experimental/react-client/cjs/react-client-flight.development.js +1.39% 100.60 kB 102.00 kB +1.47% 18.69 kB 18.96 kB
oss-experimental/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.browser.development.js +1.38% 101.46 kB 102.86 kB +1.43% 19.36 kB 19.63 kB
oss-experimental/react-server-dom-parcel/cjs/react-server-dom-parcel-client.node.development.js +1.37% 101.76 kB 103.16 kB +1.48% 19.36 kB 19.65 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-client.browser.development.js +1.37% 102.02 kB 103.42 kB +1.42% 19.49 kB 19.76 kB
oss-experimental/react-server-dom-esm/cjs/react-server-dom-esm-client.node.development.js +1.35% 103.37 kB 104.77 kB +1.42% 19.69 kB 19.97 kB
oss-experimental/react-server-dom-parcel/cjs/react-server-dom-parcel-client.edge.development.js +1.35% 103.57 kB 104.96 kB +1.53% 19.69 kB 19.99 kB
oss-experimental/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.node.development.js +1.32% 106.01 kB 107.41 kB +1.42% 20.15 kB 20.44 kB
oss-experimental/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.edge.development.js +1.30% 107.76 kB 109.16 kB +1.45% 20.47 kB 20.77 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-client.edge.development.js +1.30% 107.85 kB 109.25 kB +1.45% 20.51 kB 20.80 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.unbundled.development.js +1.29% 108.76 kB 110.15 kB +1.41% 20.41 kB 20.70 kB
oss-experimental/react-server-dom-esm/esm/react-server-dom-esm-client.browser.development.js +1.28% 139.63 kB 141.41 kB +1.46% 32.64 kB 33.11 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.development.js +1.27% 110.09 kB 111.49 kB +1.40% 20.67 kB 20.96 kB
oss-experimental/react-markup/cjs/react-markup.react-server.development.js +0.27% 514.28 kB 515.68 kB +0.25% 92.61 kB 92.84 kB

Generated by 🚫 dangerJS against 3c83561

Copy link
Collaborator

@eps1lon eps1lon left a comment

Choose a reason for hiding this comment

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

Does this reuse parallel tracks? I'd imagine we run out of parallel tracks real quick but I can also see how reusing is confusing.

@sebmarkbage
Copy link
Collaborator Author

It reuses them when we're all the way back up to the first parent that spawned the children at that level. I was originally going to try to pack children from other siblings in if the parent had space in an early finished track but that meant it would be really hard to understand which parent it belongs to since it'll look like a sibling at that level.

@sebmarkbage sebmarkbage merged commit 031230d into facebook:main Dec 16, 2024
187 checks passed
sebmarkbage added a commit that referenced this pull request Dec 16, 2024
…/Components Tracks (#31736)

Stacked on #31735.

This ensures that Server Components Track comes first. Since it's
typically rendered first on the server for initial load and then flows
into scheduler and client components work. Also puts it closer to the
Network and further away from "Main" JS.

<img width="769" alt="Screenshot 2024-12-11 at 5 31 41 PM"
src="https://github.com/user-attachments/assets/7198db0f-075e-4a78-8ea4-3bfbf06727cb"
/>

Same trick as in #31615.
davesnx added a commit to davesnx/react that referenced this pull request Dec 18, 2024
…act into issue-31578-setter-arity-gcc

* 'issue-31578-setter-arity-gcc' of github.com:/davesnx/react:
  [flags] Clean up scheduler flags (facebook#31814)
  Enable debugRenderPhaseSideEffectsForStrictMode in test renderers (facebook#31761)
  Enable disableDefaultPropsExceptForClasses (facebook#31804)
  Turn on useModernStrictMode in test renderers (facebook#31769)
  [compiler][ez] Add shape for global Object.keys (facebook#31583)
  [compiler] Context variables as dependencies (facebook#31582)
  [compiler] Add fire to known React APIs (facebook#31795)
  [compiler] Add option for firing effect functions (facebook#31794)
  [compiler][be] Logger based debug printing in test runner (facebook#31809)
  [compiler][ez] Clean up duplicate code in propagateScopeDeps (facebook#31581)
  [compiler] Repro for aliased captures within inner function expressions (facebook#31770)
  [compiler][be] Playground now compiles entire program (facebook#31774)
  [Flight] Color and badge non-primary environments (facebook#31738)
  [Flight] Emit Deduped Server Components Marker (facebook#31737)
  [Flight] Sort Server Components Track Group ahead of Client Scheduler/Components Tracks (facebook#31736)
  Clean up context access profiling experiment (facebook#31806)
  [Flight] Stack Parallel Components in Separate Tracks (facebook#31735)
  Flag for requestPaint (facebook#31805)
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