Skip to content

Commit 369c3db

Browse files
authored
Add separate ChildDeletion flag (#20264)
In the old, effect list implementation, the Deletion flag is is set on each deleted fiber. In the new, subtreeTag implementation, the Deletion flag is set on the parent of each deleted fiber, and the deleted fibers themselves are pushed to the `deletions` array. To better distinguish between these two uses, I've added a separate ChildDeletion flag. That way we can, if desired, maintain both implementations simultaneously, as we bisect to find the performance regression that we're currently investigating.
1 parent 765e89b commit 369c3db

File tree

1 file changed

+33
-26
lines changed

1 file changed

+33
-26
lines changed

packages/react-reconciler/src/ReactFiberFlags.js

+33-26
Original file line numberDiff line numberDiff line change
@@ -12,48 +12,49 @@ import {enableCreateEventHandleAPI} from 'shared/ReactFeatureFlags';
1212
export type Flags = number;
1313

1414
// Don't change these two values. They're used by React Dev Tools.
15-
export const NoFlags = /* */ 0b0000000000000000000;
16-
export const PerformedWork = /* */ 0b0000000000000000001;
15+
export const NoFlags = /* */ 0b00000000000000000000;
16+
export const PerformedWork = /* */ 0b00000000000000000001;
1717

1818
// You can change the rest (and add more).
19-
export const Placement = /* */ 0b0000000000000000010;
20-
export const Update = /* */ 0b0000000000000000100;
21-
export const PlacementAndUpdate = /* */ 0b0000000000000000110;
22-
export const Deletion = /* */ 0b0000000000000001000;
23-
export const ContentReset = /* */ 0b0000000000000010000;
24-
export const Callback = /* */ 0b0000000000000100000;
25-
export const DidCapture = /* */ 0b0000000000001000000;
26-
export const Ref = /* */ 0b0000000000010000000;
27-
export const Snapshot = /* */ 0b0000000000100000000;
28-
export const Passive = /* */ 0b0000000001000000000;
29-
export const Hydrating = /* */ 0b0000000010000000000;
30-
export const HydratingAndUpdate = /* */ 0b0000000010000000100;
31-
export const Visibility = /* */ 0b0000000100000000000;
19+
export const Placement = /* */ 0b00000000000000000010;
20+
export const Update = /* */ 0b00000000000000000100;
21+
export const PlacementAndUpdate = /* */ Placement | Update;
22+
export const Deletion = /* */ 0b00000000000000001000;
23+
export const ChildDeletion = /* */ 0b00000000000000010000;
24+
export const ContentReset = /* */ 0b00000000000000100000;
25+
export const Callback = /* */ 0b00000000000001000000;
26+
export const DidCapture = /* */ 0b00000000000010000000;
27+
export const Ref = /* */ 0b00000000000100000000;
28+
export const Snapshot = /* */ 0b00000000001000000000;
29+
export const Passive = /* */ 0b00000000010000000000;
30+
export const Hydrating = /* */ 0b00000000100000000000;
31+
export const HydratingAndUpdate = /* */ Hydrating | Update;
32+
export const Visibility = /* */ 0b00000001000000000000;
3233

3334
export const LifecycleEffectMask = Passive | Update | Callback | Ref | Snapshot;
3435

3536
// Union of all commit flags (flags with the lifetime of a particular commit)
36-
export const HostEffectMask = /* */ 0b0000000111111111111;
37+
export const HostEffectMask = /* */ 0b00000001111111111111;
3738

3839
// These are not really side effects, but we still reuse this field.
39-
export const Incomplete = /* */ 0b0000001000000000000;
40-
export const ShouldCapture = /* */ 0b0000010000000000000;
40+
export const Incomplete = /* */ 0b00000010000000000000;
41+
export const ShouldCapture = /* */ 0b00000100000000000000;
4142
// TODO (effects) Remove this bit once the new reconciler is synced to the old.
42-
export const PassiveUnmountPendingDev = /* */ 0b0000100000000000000;
43-
export const ForceUpdateForLegacySuspense = /* */ 0b0001000000000000000;
43+
export const PassiveUnmountPendingDev = /* */ 0b00001000000000000000;
44+
export const ForceUpdateForLegacySuspense = /* */ 0b00010000000000000000;
4445

4546
// Static tags describe aspects of a fiber that are not specific to a render,
4647
// e.g. a fiber uses a passive effect (even if there are no updates on this particular render).
4748
// This enables us to defer more work in the unmount case,
4849
// since we can defer traversing the tree during layout to look for Passive effects,
4950
// and instead rely on the static flag as a signal that there may be cleanup work.
50-
export const PassiveStatic = /* */ 0b0010000000000000000;
51+
export const PassiveStatic = /* */ 0b00100000000000000000;
5152

5253
// These flags allow us to traverse to fibers that have effects on mount
5354
// without traversing the entire tree after every commit for
5455
// double invoking
55-
export const MountLayoutDev = /* */ 0b0100000000000000000;
56-
export const MountPassiveDev = /* */ 0b1000000000000000000;
56+
export const MountLayoutDev = /* */ 0b01000000000000000000;
57+
export const MountPassiveDev = /* */ 0b10000000000000000000;
5758

5859
// Groups of flags that are used in the commit phase to skip over trees that
5960
// don't contain effects, by checking subtreeFlags.
@@ -65,13 +66,19 @@ export const BeforeMutationMask =
6566
// fire beforeblur
6667
// TODO: Only need to visit Deletions during BeforeMutation phase if an
6768
// element is focused.
68-
Deletion | Visibility
69+
ChildDeletion | Visibility
6970
: 0);
7071

7172
export const MutationMask =
72-
Placement | Update | Deletion | ContentReset | Ref | Hydrating | Visibility;
73+
Placement |
74+
Update |
75+
ChildDeletion |
76+
ContentReset |
77+
Ref |
78+
Hydrating |
79+
Visibility;
7380
export const LayoutMask = Update | Callback | Ref;
74-
export const PassiveMask = Passive | Deletion;
81+
export const PassiveMask = Passive | ChildDeletion;
7582

7683
// Union of tags that don't get reset on clones.
7784
// This allows certain concepts to persist without recalculting them,

0 commit comments

Comments
 (0)