Skip to content

Commit 368930d

Browse files
committed
Traverse commit phase effects iteratively
We suspect that using the JS stack to traverse through the tree in the commit phase is slower than traversing iteratively. I've kept the recursive implementation behind a flag, both so we have the option to run an experiment comparing the two, and so we can revert it easily later if needed.
1 parent 3f28b23 commit 368930d

11 files changed

+648
-39
lines changed

packages/react-reconciler/src/ReactFiberCommitWork.new.js

Lines changed: 629 additions & 18 deletions
Large diffs are not rendered by default.

packages/react-reconciler/src/ReactFiberWorkLoop.new.js

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1920,27 +1920,7 @@ function commitRootImpl(root, renderPriorityLevel) {
19201920
markLayoutEffectsStarted(lanes);
19211921
}
19221922

1923-
if (__DEV__) {
1924-
setCurrentDebugFiberInDEV(finishedWork);
1925-
invokeGuardedCallback(
1926-
null,
1927-
commitLayoutEffects,
1928-
null,
1929-
finishedWork,
1930-
root,
1931-
);
1932-
if (hasCaughtError()) {
1933-
const error = clearCaughtError();
1934-
captureCommitPhaseErrorOnRoot(finishedWork, finishedWork, error);
1935-
}
1936-
resetCurrentDebugFiberInDEV();
1937-
} else {
1938-
try {
1939-
commitLayoutEffects(finishedWork, root);
1940-
} catch (error) {
1941-
captureCommitPhaseErrorOnRoot(finishedWork, finishedWork, error);
1942-
}
1943-
}
1923+
commitLayoutEffects(finishedWork, root);
19441924

19451925
if (__DEV__) {
19461926
if (enableDebugTracing) {

packages/shared/ReactFeatureFlags.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,3 +136,5 @@ export const enableDiscreteEventFlushingChange = false;
136136
export const enableDoubleInvokingEffects = false;
137137

138138
export const enableUseRefAccessWarning = false;
139+
140+
export const enableRecursiveCommitTraversal = false;

packages/shared/forks/ReactFeatureFlags.native-fb.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ export const enableDiscreteEventFlushingChange = false;
5353
export const enableDoubleInvokingEffects = false;
5454
export const enableUseRefAccessWarning = false;
5555

56+
export const enableRecursiveCommitTraversal = false;
57+
5658
// Flow magic to verify the exports of this file match the original version.
5759
// eslint-disable-next-line no-unused-vars
5860
type Check<_X, Y: _X, X: Y = _X> = null;

packages/shared/forks/ReactFeatureFlags.native-oss.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ export const enableDiscreteEventFlushingChange = false;
5252
export const enableDoubleInvokingEffects = false;
5353
export const enableUseRefAccessWarning = false;
5454

55+
export const enableRecursiveCommitTraversal = false;
56+
5557
// Flow magic to verify the exports of this file match the original version.
5658
// eslint-disable-next-line no-unused-vars
5759
type Check<_X, Y: _X, X: Y = _X> = null;

packages/shared/forks/ReactFeatureFlags.test-renderer.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ export const enableDiscreteEventFlushingChange = false;
5252
export const enableDoubleInvokingEffects = false;
5353
export const enableUseRefAccessWarning = false;
5454

55+
export const enableRecursiveCommitTraversal = false;
56+
5557
// Flow magic to verify the exports of this file match the original version.
5658
// eslint-disable-next-line no-unused-vars
5759
type Check<_X, Y: _X, X: Y = _X> = null;

packages/shared/forks/ReactFeatureFlags.test-renderer.native.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ export const enableDiscreteEventFlushingChange = false;
5252
export const enableDoubleInvokingEffects = false;
5353
export const enableUseRefAccessWarning = false;
5454

55+
export const enableRecursiveCommitTraversal = false;
56+
5557
// Flow magic to verify the exports of this file match the original version.
5658
// eslint-disable-next-line no-unused-vars
5759
type Check<_X, Y: _X, X: Y = _X> = null;

packages/shared/forks/ReactFeatureFlags.test-renderer.www.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ export const enableDiscreteEventFlushingChange = false;
5252
export const enableDoubleInvokingEffects = false;
5353
export const enableUseRefAccessWarning = false;
5454

55+
export const enableRecursiveCommitTraversal = false;
56+
5557
// Flow magic to verify the exports of this file match the original version.
5658
// eslint-disable-next-line no-unused-vars
5759
type Check<_X, Y: _X, X: Y = _X> = null;

packages/shared/forks/ReactFeatureFlags.testing.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ export const enableDiscreteEventFlushingChange = false;
5252
export const enableDoubleInvokingEffects = false;
5353
export const enableUseRefAccessWarning = false;
5454

55+
export const enableRecursiveCommitTraversal = false;
56+
5557
// Flow magic to verify the exports of this file match the original version.
5658
// eslint-disable-next-line no-unused-vars
5759
type Check<_X, Y: _X, X: Y = _X> = null;

packages/shared/forks/ReactFeatureFlags.testing.www.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ export const enableDiscreteEventFlushingChange = true;
5252
export const enableDoubleInvokingEffects = false;
5353
export const enableUseRefAccessWarning = false;
5454

55+
export const enableRecursiveCommitTraversal = false;
56+
5557
// Flow magic to verify the exports of this file match the original version.
5658
// eslint-disable-next-line no-unused-vars
5759
type Check<_X, Y: _X, X: Y = _X> = null;

packages/shared/forks/ReactFeatureFlags.www.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ export const enableDiscreteEventFlushingChange = true;
8484
// to the correct value.
8585
export const enableNewReconciler = __VARIANT__;
8686

87+
export const enableRecursiveCommitTraversal = false;
88+
8789
// Flow magic to verify the exports of this file match the original version.
8890
// eslint-disable-next-line no-unused-vars
8991
type Check<_X, Y: _X, X: Y = _X> = null;

0 commit comments

Comments
 (0)