Skip to content

Commit 25b18d3

Browse files
authored
Traverse commit phase effects iteratively (#20094)
* Move traversal logic to ReactFiberCommitWork The current traversal logic is spread between ReactFiberWorkLoop and ReactFiberCommitWork, and it's a bit awkward, especially when refactoring. Idk the ideal module structure, so for now I'd rather keep it all in one file. * 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 06a4615 commit 25b18d3

11 files changed

+1255
-623
lines changed

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

Lines changed: 1224 additions & 126 deletions
Large diffs are not rendered by default.

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

Lines changed: 13 additions & 497 deletions
Large diffs are not rendered by default.

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)