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

[Fiber] Refactor Commit Phase into Separate Functions for Before Mutation/Mutation/Layout #31930

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

sebmarkbage
Copy link
Collaborator

Stacked on #31922.

This is doing some general clean up to be able to split the commit root three phases into three separate async steps.

This is an unusual flag that doesn't serve a special return value.

We can just use the global flag and reset it before the next mutation phase.
Unlike focusedInstanceHandle this doesn't leak any memory in the meantime.
We're already setting the update priority around user space code.
The execution scope of the commit isn't as useful for profiling information.
This aligns it with passive effects.

We can cancel these using the timeoutHandle or cancelPendingCommit.
We should never run a commit function that was cancelled.
We can check these to determine whether there are any pending commits.
Because ReactFiberLane is imported for its constants it cannot depend on
the config.
Copy link

vercel bot commented Dec 28, 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 28, 2024 8:03am

@react-sizebot
Copy link

Comparing: 50f00fd...a149d85

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.83 kB 1.83 kB
oss-stable/react-dom/cjs/react-dom-client.production.js +0.13% 511.38 kB 512.06 kB +0.20% 91.38 kB 91.57 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 +0.13% 516.17 kB 516.84 kB +0.21% 92.23 kB 92.42 kB
facebook-www/ReactDOM-prod.classic.js +0.13% 593.09 kB 593.86 kB +0.18% 104.45 kB 104.64 kB
facebook-www/ReactDOM-prod.modern.js +0.13% 583.35 kB 584.12 kB +0.18% 102.90 kB 103.09 kB

Significant size changes

Includes any change greater than 0.2%:

Expand to show
Name +/- Base Current +/- gzip Base gzip Current gzip
facebook-www/ReactART-prod.modern.js +0.32% 355.74 kB 356.90 kB +0.19% 59.67 kB 59.79 kB
facebook-www/ReactART-prod.classic.js +0.32% 365.47 kB 366.62 kB +0.23% 61.25 kB 61.39 kB
oss-stable-semver/react-art/cjs/react-art.production.js +0.31% 299.98 kB 300.91 kB +0.02% 51.28 kB 51.29 kB
oss-stable/react-art/cjs/react-art.production.js +0.31% 300.06 kB 300.98 kB +0.02% 51.30 kB 51.31 kB
oss-experimental/react-art/cjs/react-art.production.js +0.30% 304.43 kB 305.36 kB +0.02% 52.19 kB 52.19 kB
facebook-react-native/react-test-renderer/cjs/ReactTestRenderer-prod.js +0.28% 332.34 kB 333.28 kB +0.03% 58.22 kB 58.24 kB
react-native/implementations/ReactFabric-prod.js +0.26% 355.86 kB 356.79 kB +0.01% 62.08 kB 62.09 kB
react-native/implementations/ReactNativeRenderer-prod.js +0.26% 364.27 kB 365.20 kB +0.05% 63.41 kB 63.44 kB
facebook-react-native/react-test-renderer/cjs/ReactTestRenderer-profiling.js +0.25% 354.36 kB 355.25 kB +0.10% 61.29 kB 61.36 kB
react-native/implementations/ReactFabric-prod.fb.js +0.24% 380.56 kB 381.49 kB +0.02% 66.35 kB 66.36 kB
react-native/implementations/ReactNativeRenderer-prod.fb.js +0.24% 386.21 kB 387.14 kB = 67.35 kB 67.33 kB
facebook-www/ReactReconciler-prod.modern.js +0.23% 447.96 kB 448.99 kB +0.11% 72.15 kB 72.22 kB
facebook-www/ReactReconciler-prod.classic.js +0.23% 458.28 kB 459.31 kB +0.12% 73.70 kB 73.78 kB
oss-experimental/react-markup/cjs/react-markup.react-server.development.js = 520.03 kB 518.22 kB = 93.60 kB 93.27 kB
oss-experimental/react-server-dom-esm/esm/react-server-dom-esm-client.browser.development.js = 145.20 kB 143.57 kB = 34.01 kB 33.70 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.development.js = 115.84 kB 114.03 kB = 21.74 kB 21.42 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.unbundled.development.js = 114.50 kB 112.70 kB = 21.48 kB 21.16 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-client.edge.development.js = 113.60 kB 111.79 kB = 21.61 kB 21.27 kB
oss-experimental/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.edge.development.js = 113.51 kB 111.70 kB = 21.57 kB 21.23 kB
oss-experimental/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.node.development.js = 111.76 kB 109.95 kB = 21.22 kB 20.90 kB
oss-experimental/react-server-dom-parcel/cjs/react-server-dom-parcel-client.edge.development.js = 109.31 kB 107.51 kB = 20.78 kB 20.45 kB
oss-experimental/react-server-dom-esm/cjs/react-server-dom-esm-client.node.development.js = 109.12 kB 107.32 kB = 20.74 kB 20.43 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-client.browser.development.js = 107.77 kB 105.96 kB = 20.57 kB 20.24 kB
oss-experimental/react-server-dom-parcel/cjs/react-server-dom-parcel-client.node.development.js = 107.51 kB 105.71 kB = 20.42 kB 20.11 kB
oss-experimental/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.browser.development.js = 107.21 kB 105.40 kB = 20.44 kB 20.11 kB
oss-experimental/react-client/cjs/react-client-flight.development.js = 106.35 kB 104.54 kB = 19.78 kB 19.46 kB
oss-experimental/react-server-dom-esm/cjs/react-server-dom-esm-client.browser.development.js = 105.02 kB 103.22 kB = 20.05 kB 19.71 kB
oss-experimental/react-server-dom-parcel/cjs/react-server-dom-parcel-client.browser.development.js = 104.90 kB 103.10 kB = 19.88 kB 19.55 kB

Generated by 🚫 dangerJS against facd6aa

@@ -744,6 +744,7 @@ describe('ReactDeferredValue', () => {
</Container>,
);
// We should switch to pre-rendering the new preview.
await waitForPaint([]);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This happens because the requestPaint() is now unconditional even if there weren't any effects. Which doesn't really hurt anything since it's actually a noop in anything but tests and should probably go away.

@@ -3460,7 +3471,8 @@ function commitRootImpl(
}
}

onCommitRootDevTools(finishedWork.stateNode, renderPriorityLevel);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This one is a bit strange because the profiler in devtools tracks the priority level that the commit phase is running in rather than what priority was rendered and then committed. I think the idea is that it would be running in the scheduler priority of the render but that's not necessarily the case for the commit.

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.

3 participants