Skip to content

Commit 9f85d07

Browse files
committed
Batch sync, default and continuous lanes (#25700)
<!-- Thanks for submitting a pull request! We appreciate you spending the time to work on these changes. Please provide enough information so that others can review your pull request. The three fields below are mandatory. Before submitting a pull request, please make sure the following is done: 1. Fork [the repository](https://github.com/facebook/react) and create your branch from `main`. 2. Run `yarn` in the repository root. 3. If you've fixed a bug or added code that should be tested, add tests! 4. Ensure the test suite passes (`yarn test`). Tip: `yarn test --watch TestName` is helpful in development. 5. Run `yarn test --prod` to test in the production environment. It supports the same options as `yarn test`. 6. If you need a debugger, run `yarn debug-test --watch TestName`, open `chrome://inspect`, and press "Inspect". 7. Format your code with [prettier](https://github.com/prettier/prettier) (`yarn prettier`). 8. Make sure your code lints (`yarn lint`). Tip: `yarn linc` to only check changed files. 9. Run the [Flow](https://flowtype.org/) type checks (`yarn flow`). 10. If you haven't already, complete the CLA. Learn more about contributing: https://reactjs.org/docs/how-to-contribute.html --> ## Summary <!-- Explain the **motivation** for making this change. What existing problem does the pull request solve? --> This is the other approach for unifying default and sync lane #25524. The approach in that PR is to merge default and continuous lane into the sync lane, and use a new field to track the priority. But there are a couple places that field will be needed, and it is difficult to correctly reset the field when there is no sync lane. In this PR we take the other approach that doesn't remove any lane, but batch them to get the behavior we want. ## How did you test this change? <!-- Demonstrate the code is solid. Example: The exact commands you ran and their output, screenshots / videos if the pull request changes the user interface. How exactly did you verify that your PR solves the issue you wanted to solve? If you leave this empty, your PR will very likely be closed. --> yarn test Co-authored-by: Andrew Clark <[email protected]> DiffTrain build for [5379b61](5379b61) [View git log for this commit](https://github.com/facebook/react/commits/5379b6123f171bb48cc8a9c435c11ccb9f8ff0e7)
1 parent f7173f1 commit 9f85d07

37 files changed

+838
-673
lines changed

compiled/facebook-www/JSXDEVRuntime-dev.classic.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ var disableInputAttributeSyncing =
131131
enableLazyContextPropagation =
132132
dynamicFeatureFlags.enableLazyContextPropagation,
133133
enableSyncDefaultUpdates = dynamicFeatureFlags.enableSyncDefaultUpdates,
134+
enableUnifiedSyncLane = dynamicFeatureFlags.enableUnifiedSyncLane,
134135
enableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay =
135136
dynamicFeatureFlags.enableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay,
136137
enableClientRenderFallbackOnTextMismatch =

compiled/facebook-www/JSXDEVRuntime-dev.modern.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ var disableInputAttributeSyncing =
131131
enableLazyContextPropagation =
132132
dynamicFeatureFlags.enableLazyContextPropagation,
133133
enableSyncDefaultUpdates = dynamicFeatureFlags.enableSyncDefaultUpdates,
134+
enableUnifiedSyncLane = dynamicFeatureFlags.enableUnifiedSyncLane,
134135
enableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay =
135136
dynamicFeatureFlags.enableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay,
136137
enableClientRenderFallbackOnTextMismatch =

compiled/facebook-www/REVISION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
b83baf63f71669ca7bf222afec305b7a6fd782b7
1+
5379b6123f171bb48cc8a9c435c11ccb9f8ff0e7
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
b83baf63f71669ca7bf222afec305b7a6fd782b7
1+
5379b6123f171bb48cc8a9c435c11ccb9f8ff0e7

compiled/facebook-www/React-dev.classic.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ if (
2727
}
2828
"use strict";
2929

30-
var ReactVersion = "18.3.0-www-classic-b83baf63f-20230105";
30+
var ReactVersion = "18.3.0-www-classic-5379b6123-20230105";
3131

3232
// ATTENTION
3333
// When adding new symbols to this file,
@@ -502,6 +502,7 @@ var disableInputAttributeSyncing =
502502
enableLazyContextPropagation =
503503
dynamicFeatureFlags.enableLazyContextPropagation,
504504
enableSyncDefaultUpdates = dynamicFeatureFlags.enableSyncDefaultUpdates,
505+
enableUnifiedSyncLane = dynamicFeatureFlags.enableUnifiedSyncLane,
505506
enableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay =
506507
dynamicFeatureFlags.enableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay,
507508
enableClientRenderFallbackOnTextMismatch =

compiled/facebook-www/React-dev.modern.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ if (
2727
}
2828
"use strict";
2929

30-
var ReactVersion = "18.3.0-www-modern-b83baf63f-20230105";
30+
var ReactVersion = "18.3.0-www-modern-5379b6123-20230105";
3131

3232
// ATTENTION
3333
// When adding new symbols to this file,
@@ -502,6 +502,7 @@ var disableInputAttributeSyncing =
502502
enableLazyContextPropagation =
503503
dynamicFeatureFlags.enableLazyContextPropagation,
504504
enableSyncDefaultUpdates = dynamicFeatureFlags.enableSyncDefaultUpdates,
505+
enableUnifiedSyncLane = dynamicFeatureFlags.enableUnifiedSyncLane,
505506
enableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay =
506507
dynamicFeatureFlags.enableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay,
507508
enableClientRenderFallbackOnTextMismatch =

compiled/facebook-www/React-prod.classic.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -643,4 +643,4 @@ exports.useSyncExternalStore = function(
643643
);
644644
};
645645
exports.useTransition = useTransition;
646-
exports.version = "18.3.0-www-classic-b83baf63f-20230105";
646+
exports.version = "18.3.0-www-classic-5379b6123-20230105";

compiled/facebook-www/React-prod.modern.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -635,4 +635,4 @@ exports.useSyncExternalStore = function(
635635
);
636636
};
637637
exports.useTransition = useTransition;
638-
exports.version = "18.3.0-www-modern-b83baf63f-20230105";
638+
exports.version = "18.3.0-www-modern-5379b6123-20230105";

compiled/facebook-www/React-profiling.classic.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,7 @@ exports.useSyncExternalStore = function(
654654
);
655655
};
656656
exports.useTransition = useTransition;
657-
exports.version = "18.3.0-www-classic-b83baf63f-20230105";
657+
exports.version = "18.3.0-www-classic-5379b6123-20230105";
658658

659659
/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
660660
if (

compiled/facebook-www/React-profiling.modern.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ exports.useSyncExternalStore = function(
646646
);
647647
};
648648
exports.useTransition = useTransition;
649-
exports.version = "18.3.0-www-modern-b83baf63f-20230105";
649+
exports.version = "18.3.0-www-modern-5379b6123-20230105";
650650

651651
/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
652652
if (

compiled/facebook-www/ReactART-dev.classic.js

Lines changed: 57 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ function _assertThisInitialized(self) {
6969
return self;
7070
}
7171

72-
var ReactVersion = "18.3.0-www-classic-b83baf63f-20230105";
72+
var ReactVersion = "18.3.0-www-classic-5379b6123-20230105";
7373

7474
var LegacyRoot = 0;
7575
var ConcurrentRoot = 1;
@@ -191,6 +191,7 @@ var disableInputAttributeSyncing =
191191
enableLazyContextPropagation =
192192
dynamicFeatureFlags.enableLazyContextPropagation,
193193
enableSyncDefaultUpdates = dynamicFeatureFlags.enableSyncDefaultUpdates,
194+
enableUnifiedSyncLane = dynamicFeatureFlags.enableUnifiedSyncLane,
194195
enableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay =
195196
dynamicFeatureFlags.enableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay,
196197
enableClientRenderFallbackOnTextMismatch =
@@ -1596,6 +1597,9 @@ var DefaultHydrationLane =
15961597
var DefaultLane =
15971598
/* */
15981599
32;
1600+
var SyncUpdateLanes =
1601+
/* */
1602+
42;
15991603
var TransitionHydrationLane =
16001604
/* */
16011605
64;
@@ -1743,6 +1747,14 @@ var nextTransitionLane = TransitionLane1;
17431747
var nextRetryLane = RetryLane1;
17441748

17451749
function getHighestPriorityLanes(lanes) {
1750+
if (enableUnifiedSyncLane) {
1751+
var pendingSyncLanes = lanes & SyncUpdateLanes;
1752+
1753+
if (pendingSyncLanes !== 0) {
1754+
return pendingSyncLanes;
1755+
}
1756+
}
1757+
17461758
switch (getHighestPriorityLane(lanes)) {
17471759
case SyncHydrationLane:
17481760
return SyncHydrationLane;
@@ -2317,51 +2329,55 @@ function getBumpedLaneForHydration(root, renderLanes) {
23172329
var renderLane = getHighestPriorityLane(renderLanes);
23182330
var lane;
23192331

2320-
switch (renderLane) {
2321-
case SyncLane:
2322-
lane = SyncHydrationLane;
2323-
break;
2332+
if (enableUnifiedSyncLane && (renderLane & SyncUpdateLanes) !== NoLane) {
2333+
lane = SyncHydrationLane;
2334+
} else {
2335+
switch (renderLane) {
2336+
case SyncLane:
2337+
lane = SyncHydrationLane;
2338+
break;
23242339

2325-
case InputContinuousLane:
2326-
lane = InputContinuousHydrationLane;
2327-
break;
2340+
case InputContinuousLane:
2341+
lane = InputContinuousHydrationLane;
2342+
break;
23282343

2329-
case DefaultLane:
2330-
lane = DefaultHydrationLane;
2331-
break;
2344+
case DefaultLane:
2345+
lane = DefaultHydrationLane;
2346+
break;
23322347

2333-
case TransitionLane1:
2334-
case TransitionLane2:
2335-
case TransitionLane3:
2336-
case TransitionLane4:
2337-
case TransitionLane5:
2338-
case TransitionLane6:
2339-
case TransitionLane7:
2340-
case TransitionLane8:
2341-
case TransitionLane9:
2342-
case TransitionLane10:
2343-
case TransitionLane11:
2344-
case TransitionLane12:
2345-
case TransitionLane13:
2346-
case TransitionLane14:
2347-
case TransitionLane15:
2348-
case TransitionLane16:
2349-
case RetryLane1:
2350-
case RetryLane2:
2351-
case RetryLane3:
2352-
case RetryLane4:
2353-
lane = TransitionHydrationLane;
2354-
break;
2348+
case TransitionLane1:
2349+
case TransitionLane2:
2350+
case TransitionLane3:
2351+
case TransitionLane4:
2352+
case TransitionLane5:
2353+
case TransitionLane6:
2354+
case TransitionLane7:
2355+
case TransitionLane8:
2356+
case TransitionLane9:
2357+
case TransitionLane10:
2358+
case TransitionLane11:
2359+
case TransitionLane12:
2360+
case TransitionLane13:
2361+
case TransitionLane14:
2362+
case TransitionLane15:
2363+
case TransitionLane16:
2364+
case RetryLane1:
2365+
case RetryLane2:
2366+
case RetryLane3:
2367+
case RetryLane4:
2368+
lane = TransitionHydrationLane;
2369+
break;
23552370

2356-
case IdleLane:
2357-
lane = IdleHydrationLane;
2358-
break;
2371+
case IdleLane:
2372+
lane = IdleHydrationLane;
2373+
break;
23592374

2360-
default:
2361-
// Everything else is already either a hydration lane, or shouldn't
2362-
// be retried at a hydration lane.
2363-
lane = NoLane;
2364-
break;
2375+
default:
2376+
// Everything else is already either a hydration lane, or shouldn't
2377+
// be retried at a hydration lane.
2378+
lane = NoLane;
2379+
break;
2380+
}
23652381
} // Check if the lane we chose is suspended. If so, that indicates that we
23662382
// already attempted and failed to hydrate at that level. Also check if we're
23672383
// already rendering that lane, which is rare but could happen.

compiled/facebook-www/ReactART-dev.modern.js

Lines changed: 57 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ function _assertThisInitialized(self) {
6969
return self;
7070
}
7171

72-
var ReactVersion = "18.3.0-www-modern-b83baf63f-20230105";
72+
var ReactVersion = "18.3.0-www-modern-5379b6123-20230105";
7373

7474
var LegacyRoot = 0;
7575
var ConcurrentRoot = 1;
@@ -191,6 +191,7 @@ var disableInputAttributeSyncing =
191191
enableLazyContextPropagation =
192192
dynamicFeatureFlags.enableLazyContextPropagation,
193193
enableSyncDefaultUpdates = dynamicFeatureFlags.enableSyncDefaultUpdates,
194+
enableUnifiedSyncLane = dynamicFeatureFlags.enableUnifiedSyncLane,
194195
enableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay =
195196
dynamicFeatureFlags.enableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay,
196197
enableClientRenderFallbackOnTextMismatch =
@@ -1593,6 +1594,9 @@ var DefaultHydrationLane =
15931594
var DefaultLane =
15941595
/* */
15951596
32;
1597+
var SyncUpdateLanes =
1598+
/* */
1599+
42;
15961600
var TransitionHydrationLane =
15971601
/* */
15981602
64;
@@ -1740,6 +1744,14 @@ var nextTransitionLane = TransitionLane1;
17401744
var nextRetryLane = RetryLane1;
17411745

17421746
function getHighestPriorityLanes(lanes) {
1747+
if (enableUnifiedSyncLane) {
1748+
var pendingSyncLanes = lanes & SyncUpdateLanes;
1749+
1750+
if (pendingSyncLanes !== 0) {
1751+
return pendingSyncLanes;
1752+
}
1753+
}
1754+
17431755
switch (getHighestPriorityLane(lanes)) {
17441756
case SyncHydrationLane:
17451757
return SyncHydrationLane;
@@ -2314,51 +2326,55 @@ function getBumpedLaneForHydration(root, renderLanes) {
23142326
var renderLane = getHighestPriorityLane(renderLanes);
23152327
var lane;
23162328

2317-
switch (renderLane) {
2318-
case SyncLane:
2319-
lane = SyncHydrationLane;
2320-
break;
2329+
if (enableUnifiedSyncLane && (renderLane & SyncUpdateLanes) !== NoLane) {
2330+
lane = SyncHydrationLane;
2331+
} else {
2332+
switch (renderLane) {
2333+
case SyncLane:
2334+
lane = SyncHydrationLane;
2335+
break;
23212336

2322-
case InputContinuousLane:
2323-
lane = InputContinuousHydrationLane;
2324-
break;
2337+
case InputContinuousLane:
2338+
lane = InputContinuousHydrationLane;
2339+
break;
23252340

2326-
case DefaultLane:
2327-
lane = DefaultHydrationLane;
2328-
break;
2341+
case DefaultLane:
2342+
lane = DefaultHydrationLane;
2343+
break;
23292344

2330-
case TransitionLane1:
2331-
case TransitionLane2:
2332-
case TransitionLane3:
2333-
case TransitionLane4:
2334-
case TransitionLane5:
2335-
case TransitionLane6:
2336-
case TransitionLane7:
2337-
case TransitionLane8:
2338-
case TransitionLane9:
2339-
case TransitionLane10:
2340-
case TransitionLane11:
2341-
case TransitionLane12:
2342-
case TransitionLane13:
2343-
case TransitionLane14:
2344-
case TransitionLane15:
2345-
case TransitionLane16:
2346-
case RetryLane1:
2347-
case RetryLane2:
2348-
case RetryLane3:
2349-
case RetryLane4:
2350-
lane = TransitionHydrationLane;
2351-
break;
2345+
case TransitionLane1:
2346+
case TransitionLane2:
2347+
case TransitionLane3:
2348+
case TransitionLane4:
2349+
case TransitionLane5:
2350+
case TransitionLane6:
2351+
case TransitionLane7:
2352+
case TransitionLane8:
2353+
case TransitionLane9:
2354+
case TransitionLane10:
2355+
case TransitionLane11:
2356+
case TransitionLane12:
2357+
case TransitionLane13:
2358+
case TransitionLane14:
2359+
case TransitionLane15:
2360+
case TransitionLane16:
2361+
case RetryLane1:
2362+
case RetryLane2:
2363+
case RetryLane3:
2364+
case RetryLane4:
2365+
lane = TransitionHydrationLane;
2366+
break;
23522367

2353-
case IdleLane:
2354-
lane = IdleHydrationLane;
2355-
break;
2368+
case IdleLane:
2369+
lane = IdleHydrationLane;
2370+
break;
23562371

2357-
default:
2358-
// Everything else is already either a hydration lane, or shouldn't
2359-
// be retried at a hydration lane.
2360-
lane = NoLane;
2361-
break;
2372+
default:
2373+
// Everything else is already either a hydration lane, or shouldn't
2374+
// be retried at a hydration lane.
2375+
lane = NoLane;
2376+
break;
2377+
}
23622378
} // Check if the lane we chose is suspended. If so, that indicates that we
23632379
// already attempted and failed to hydrate at that level. Also check if we're
23642380
// already rendering that lane, which is rare but could happen.

0 commit comments

Comments
 (0)