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

Parallel transitions: Assign different lanes to consecutive transitions #20672

Open
wants to merge 1 commit into
base: master
from

Conversation

@acdlite
Copy link
Member

@acdlite acdlite commented Jan 27, 2021

Currently we always assign the same lane to all transitions. This means if there are two pending transitions at the same time, neither transition can finish until both can finish, even if they affect completely separate parts of the UI.

The new approach is to assign a different lane to each consecutive transition, by shifting the bit to the right each time. When we reach the end of the bit range, we cycle back to the first bit. In practice, this should mean that all transitions get their own dedicated lane, unless we have more pending transitions than lanes, which should be rare.

We retain our existing behavior of assigning the same lane to all transitions within the same event. This is achieved by caching the first lane assigned to a transition, then re-using that one until the next React task, by which point the event must have finished. This preserves the guarantee that all transition updates that result from a single event will be consistent.

@codesandbox
Copy link

@codesandbox codesandbox bot commented Jan 27, 2021

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 3cc1f20:

Sandbox Source
React Configuration
@sizebot
Copy link

@sizebot sizebot commented Jan 27, 2021

Details of bundled changes.

Comparing: aa736a0...3cc1f20

react-dom

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-dom-server.browser.development.js 0.0% 0.0% 145.08 KB 145.08 KB 36.93 KB 36.93 KB UMD_DEV
react-dom-server.node.development.js 0.0% 0.0% 138.89 KB 138.89 KB 36.75 KB 36.75 KB NODE_DEV
react-dom-server.browser.production.min.js 0.0% 0.0% 20.42 KB 20.42 KB 7.57 KB 7.57 KB UMD_PROD
ReactDOMTesting-prod.js 0.0% 0.0% 374.97 KB 374.97 KB 71.16 KB 71.16 KB FB_WWW_PROD
react-dom.development.js 0.0% 0.0% 979.67 KB 979.67 KB 214.09 KB 214.09 KB UMD_DEV
react-dom.production.min.js 0.0% -0.0% 124.83 KB 124.83 KB 40.98 KB 40.98 KB UMD_PROD
react-dom.profiling.min.js 0.0% 0.0% 130.52 KB 130.52 KB 42.71 KB 42.71 KB UMD_PROFILING
react-dom.development.js 0.0% 0.0% 932.3 KB 932.3 KB 211.25 KB 211.25 KB NODE_DEV
ReactDOMForked-dev.js -0.1% -0.1% 999.22 KB 998.18 KB 221.75 KB 221.56 KB FB_WWW_DEV
react-dom-unstable-fizz.browser.production.min.js 0.0% 🔺+0.1% 1.22 KB 1.22 KB 711 B 712 B UMD_PROD
react-dom-unstable-fizz.node.production.min.js 0.0% 🔺+0.2% 1.17 KB 1.17 KB 666 B 667 B NODE_PROD
react-dom.production.min.js 0.0% -0.0% 124.99 KB 124.99 KB 40.33 KB 40.32 KB NODE_PROD
ReactDOMForked-prod.js -0.1% -0.1% 384.07 KB 383.81 KB 71.58 KB 71.52 KB FB_WWW_PROD
react-dom.profiling.min.js 0.0% -0.0% 130.86 KB 130.86 KB 42.05 KB 42.04 KB NODE_PROFILING
ReactDOMForked-profiling.js -0.1% -0.1% 402.46 KB 402.2 KB 74.77 KB 74.71 KB FB_WWW_PROFILING
ReactDOM-dev.js 0.0% 0.0% 993.95 KB 993.95 KB 220.85 KB 220.85 KB FB_WWW_DEV
react-dom-unstable-fizz.browser.production.min.js 0.0% 🔺+0.2% 1.01 KB 1.01 KB 615 B 616 B NODE_PROD
react-dom-server.browser.development.js 0.0% 0.0% 137.62 KB 137.62 KB 36.5 KB 36.5 KB NODE_DEV
react-dom-server.browser.production.min.js 0.0% 0.0% 20.33 KB 20.33 KB 7.53 KB 7.53 KB NODE_PROD
react-dom-test-utils.development.js 0.0% 0.0% 71.37 KB 71.37 KB 19.33 KB 19.33 KB UMD_DEV
ReactDOMServer-dev.js 0.0% -0.0% 142.43 KB 142.43 KB 36.6 KB 36.6 KB FB_WWW_DEV
react-dom-test-utils.production.min.js 0.0% -0.0% 13.71 KB 13.71 KB 5.32 KB 5.32 KB UMD_PROD
ReactDOMTesting-dev.js 0.0% 0.0% 918.15 KB 918.15 KB 206.67 KB 206.67 KB FB_WWW_DEV

ReactDOM: size: 0.0%, gzip: 0.0%

Size changes (experimental)

Generated by 🚫 dangerJS against 3cc1f20

@sizebot
Copy link

@sizebot sizebot commented Jan 27, 2021

Details of bundled changes.

Comparing: aa736a0...3cc1f20

react-dom

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
ReactDOM-profiling.js 0.0% 0.0% 410.98 KB 410.98 KB 75.91 KB 75.91 KB FB_WWW_PROFILING
react-dom-server.browser.development.js 0.0% 0.0% 143.17 KB 143.17 KB 36.66 KB 36.67 KB UMD_DEV
react-dom-server.node.development.js 0.0% 0.0% 137.09 KB 137.09 KB 36.46 KB 36.46 KB NODE_DEV
react-dom-server.node.production.min.js 0.0% 0.0% 20.19 KB 20.19 KB 7.58 KB 7.58 KB NODE_PROD
react-dom.development.js 0.0% 0.0% 927.13 KB 927.13 KB 203.99 KB 204 KB UMD_DEV
react-dom.production.min.js 0.0% 0.0% 118.46 KB 118.46 KB 38.99 KB 38.99 KB UMD_PROD
react-dom.profiling.min.js 0.0% -0.0% 122.56 KB 122.56 KB 40.25 KB 40.25 KB UMD_PROFILING
react-dom.development.js 0.0% 0.0% 882.25 KB 882.25 KB 201.4 KB 201.4 KB NODE_DEV
ReactDOMForked-dev.js -0.1% -0.1% 1 MB 1023.77 KB 226.56 KB 226.36 KB FB_WWW_DEV
react-dom.production.min.js 0.0% -0.0% 118.55 KB 118.55 KB 38.31 KB 38.31 KB NODE_PROD
ReactDOMForked-prod.js -0.1% -0.1% 395.45 KB 395.18 KB 73.31 KB 73.25 KB FB_WWW_PROD
react-dom.profiling.min.js 0.0% -0.0% 122.8 KB 122.8 KB 39.58 KB 39.57 KB NODE_PROFILING
ReactDOMForked-profiling.js -0.1% -0.1% 413.88 KB 413.62 KB 76.5 KB 76.45 KB FB_WWW_PROFILING
react-dom-server.browser.development.js 0.0% 0.0% 135.82 KB 135.82 KB 36.21 KB 36.21 KB NODE_DEV
react-dom-test-utils.development.js 0.0% 0.0% 71.36 KB 71.36 KB 19.32 KB 19.32 KB UMD_DEV
ReactDOMServer-dev.js 0.0% 0.0% 146.46 KB 146.46 KB 37.61 KB 37.62 KB FB_WWW_DEV
ReactDOMServer-prod.js 0.0% 0.0% 47.44 KB 47.44 KB 11.06 KB 11.06 KB FB_WWW_PROD
react-dom-test-utils.development.js 0.0% -0.0% 66.17 KB 66.17 KB 18.8 KB 18.8 KB NODE_DEV
ReactDOMTesting-dev.js 0.0% 0.0% 946.49 KB 946.49 KB 212.35 KB 212.35 KB FB_WWW_DEV

Size changes (stable)

Generated by 🚫 dangerJS against 3cc1f20

@acdlite acdlite force-pushed the acdlite:parallel-transitions branch 2 times, most recently from d725f0d to a40a8d0 Jan 27, 2021
// effect of interrupting the current work-in-progress.
lane = pickArbitraryLane(TransitionLanes);
}
export function claimNextTransitionLane(): Lane {

This comment has been minimized.

@acdlite

acdlite Jan 27, 2021
Author Member

This is the essential part

@acdlite acdlite force-pushed the acdlite:parallel-transitions branch from a40a8d0 to dc4f8df Jan 27, 2021
Currently we always assign the same lane to all transitions. This means
if there are two pending transitions at the same time, neither
transition can finish until both can finish, even if they affect
completely separate parts of the UI.

The new approach is to assign a different lane to each consecutive
transition, by shifting the bit to the right each time. When we reach
the end of the bit range, we cycle back to the first bit. In practice,
this should mean that all transitions get their own dedicated lane,
unless we have more pending transitions than lanes, which should
be rare.

We retain our existing behavior of assigning the same lane to all
transitions within the same event. This is achieved by caching the first
lane assigned to a transition, then re-using that one until the next
React task, by which point the event must have finished. This preserves
the guarantee that all transition updates that result from a single
event will be consistent.
@acdlite acdlite force-pushed the acdlite:parallel-transitions branch 2 times, most recently from 104d586 to 3cc1f20 Jan 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants