Skip to content

Commit a5d2d83

Browse files
committed
[cleanup] remove deletedTreeCleanUpLevel feature flag (#25529)
I noticed this was an experiment concluded 16 months ago (#21679) that this extra work is beneficial to break up cycles leaking memory in product code. DiffTrain build for [ee85098](ee85098) [View git log for this commit](https://github.com/facebook/react/commits/ee85098019bf9703b32f608f8bbd5f8fb1a7d60b)
1 parent 8e31656 commit a5d2d83

28 files changed

+512
-680
lines changed

compiled/facebook-www/REVISION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
4f8ffec453c41fcb6e98cb4e003f7319bb1c81b9
1+
ee85098019bf9703b32f608f8bbd5f8fb1a7d60b
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
4f8ffec453c41fcb6e98cb4e003f7319bb1c81b9
1+
ee85098019bf9703b32f608f8bbd5f8fb1a7d60b

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

Lines changed: 1 addition & 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-4f8ffec45-20230115";
30+
var ReactVersion = "18.3.0-www-classic-ee8509801-20230117";
3131

3232
// ATTENTION
3333
// When adding new symbols to this file,

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

Lines changed: 1 addition & 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-4f8ffec45-20230115";
30+
var ReactVersion = "18.3.0-www-modern-ee8509801-20230117";
3131

3232
// ATTENTION
3333
// When adding new symbols to this file,

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-4f8ffec45-20230115";
646+
exports.version = "18.3.0-www-classic-ee8509801-20230117";

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-4f8ffec45-20230115";
638+
exports.version = "18.3.0-www-modern-ee8509801-20230117";

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-4f8ffec45-20230115";
657+
exports.version = "18.3.0-www-classic-ee8509801-20230117";
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-4f8ffec45-20230115";
649+
exports.version = "18.3.0-www-modern-ee8509801-20230117";
650650

651651
/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
652652
if (

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

Lines changed: 58 additions & 79 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-4f8ffec45-20230115";
72+
var ReactVersion = "18.3.0-www-classic-ee8509801-20230117";
7373

7474
var LegacyRoot = 0;
7575
var ConcurrentRoot = 1;
@@ -20273,55 +20273,40 @@ function detachFiberAfterEffects(fiber) {
2027320273
if (alternate !== null) {
2027420274
fiber.alternate = null;
2027520275
detachFiberAfterEffects(alternate);
20276-
} // Note: Defensively using negation instead of < in case
20277-
// `deletedTreeCleanUpLevel` is undefined.
20276+
} // Clear cyclical Fiber fields. This level alone is designed to roughly
20277+
// approximate the planned Fiber refactor. In that world, `setState` will be
20278+
// bound to a special "instance" object instead of a Fiber. The Instance
20279+
// object will not have any of these fields. It will only be connected to
20280+
// the fiber tree via a single link at the root. So if this level alone is
20281+
// sufficient to fix memory issues, that bodes well for our plans.
2027820282

20279-
{
20280-
// Clear cyclical Fiber fields. This level alone is designed to roughly
20281-
// approximate the planned Fiber refactor. In that world, `setState` will be
20282-
// bound to a special "instance" object instead of a Fiber. The Instance
20283-
// object will not have any of these fields. It will only be connected to
20284-
// the fiber tree via a single link at the root. So if this level alone is
20285-
// sufficient to fix memory issues, that bodes well for our plans.
20286-
fiber.child = null;
20287-
fiber.deletions = null;
20288-
fiber.sibling = null; // The `stateNode` is cyclical because on host nodes it points to the host
20289-
// tree, which has its own pointers to children, parents, and siblings.
20290-
// The other host nodes also point back to fibers, so we should detach that
20291-
// one, too.
20283+
fiber.child = null;
20284+
fiber.deletions = null;
20285+
fiber.sibling = null; // The `stateNode` is cyclical because on host nodes it points to the host
20286+
// tree, which has its own pointers to children, parents, and siblings.
20287+
// The other host nodes also point back to fibers, so we should detach that
20288+
// one, too.
2029220289

20293-
if (fiber.tag === HostComponent) {
20294-
var hostInstance = fiber.stateNode;
20295-
}
20290+
if (fiber.tag === HostComponent) {
20291+
var hostInstance = fiber.stateNode;
20292+
}
2029620293

20297-
fiber.stateNode = null; // I'm intentionally not clearing the `return` field in this level. We
20298-
// already disconnect the `return` pointer at the root of the deleted
20299-
// subtree (in `detachFiberMutation`). Besides, `return` by itself is not
20300-
// cyclical — it's only cyclical when combined with `child`, `sibling`, and
20301-
// `alternate`. But we'll clear it in the next level anyway, just in case.
20294+
fiber.stateNode = null;
2030220295

20303-
{
20304-
fiber._debugOwner = null;
20305-
}
20296+
{
20297+
fiber._debugOwner = null;
20298+
} // Theoretically, nothing in here should be necessary, because we already
20299+
// disconnected the fiber from the tree. So even if something leaks this
20300+
// particular fiber, it won't leak anything else.
2030620301

20307-
{
20308-
// Theoretically, nothing in here should be necessary, because we already
20309-
// disconnected the fiber from the tree. So even if something leaks this
20310-
// particular fiber, it won't leak anything else
20311-
//
20312-
// The purpose of this branch is to be super aggressive so we can measure
20313-
// if there's any difference in memory impact. If there is, that could
20314-
// indicate a React leak we don't know about.
20315-
fiber.return = null;
20316-
fiber.dependencies = null;
20317-
fiber.memoizedProps = null;
20318-
fiber.memoizedState = null;
20319-
fiber.pendingProps = null;
20320-
fiber.stateNode = null; // TODO: Move to `commitPassiveUnmountInsideDeletedTreeOnFiber` instead.
20302+
fiber.return = null;
20303+
fiber.dependencies = null;
20304+
fiber.memoizedProps = null;
20305+
fiber.memoizedState = null;
20306+
fiber.pendingProps = null;
20307+
fiber.stateNode = null; // TODO: Move to `commitPassiveUnmountInsideDeletedTreeOnFiber` instead.
2032120308

20322-
fiber.updateQueue = null;
20323-
}
20324-
}
20309+
fiber.updateQueue = null;
2032520310
}
2032620311

2032720312
function getHostParentFiber(fiber) {
@@ -22398,33 +22383,31 @@ function commitPassiveUnmountEffects(finishedWork) {
2239822383
}
2239922384

2240022385
function detachAlternateSiblings(parentFiber) {
22401-
{
22402-
// A fiber was deleted from this parent fiber, but it's still part of the
22403-
// previous (alternate) parent fiber's list of children. Because children
22404-
// are a linked list, an earlier sibling that's still alive will be
22405-
// connected to the deleted fiber via its `alternate`:
22406-
//
22407-
// live fiber --alternate--> previous live fiber --sibling--> deleted
22408-
// fiber
22409-
//
22410-
// We can't disconnect `alternate` on nodes that haven't been deleted yet,
22411-
// but we can disconnect the `sibling` and `child` pointers.
22412-
var previousFiber = parentFiber.alternate;
22386+
// A fiber was deleted from this parent fiber, but it's still part of the
22387+
// previous (alternate) parent fiber's list of children. Because children
22388+
// are a linked list, an earlier sibling that's still alive will be
22389+
// connected to the deleted fiber via its `alternate`:
22390+
//
22391+
// live fiber --alternate--> previous live fiber --sibling--> deleted
22392+
// fiber
22393+
//
22394+
// We can't disconnect `alternate` on nodes that haven't been deleted yet,
22395+
// but we can disconnect the `sibling` and `child` pointers.
22396+
var previousFiber = parentFiber.alternate;
2241322397

22414-
if (previousFiber !== null) {
22415-
var detachedChild = previousFiber.child;
22398+
if (previousFiber !== null) {
22399+
var detachedChild = previousFiber.child;
2241622400

22417-
if (detachedChild !== null) {
22418-
previousFiber.child = null;
22401+
if (detachedChild !== null) {
22402+
previousFiber.child = null;
2241922403

22420-
do {
22421-
// $FlowFixMe[incompatible-use] found when upgrading Flow
22422-
var detachedSibling = detachedChild.sibling; // $FlowFixMe[incompatible-use] found when upgrading Flow
22404+
do {
22405+
// $FlowFixMe[incompatible-use] found when upgrading Flow
22406+
var detachedSibling = detachedChild.sibling; // $FlowFixMe[incompatible-use] found when upgrading Flow
2242322407

22424-
detachedChild.sibling = null;
22425-
detachedChild = detachedSibling;
22426-
} while (detachedChild !== null);
22427-
}
22408+
detachedChild.sibling = null;
22409+
detachedChild = detachedSibling;
22410+
} while (detachedChild !== null);
2242822411
}
2242922412
}
2243022413
}
@@ -22617,8 +22600,7 @@ function commitPassiveUnmountEffectsInsideOfDeletedTree_begin(
2261722600
setCurrentFiber(fiber);
2261822601
commitPassiveUnmountInsideDeletedTreeOnFiber(fiber, nearestMountedAncestor);
2261922602
resetCurrentFiber();
22620-
var child = fiber.child; // TODO: Only traverse subtree if it has a PassiveStatic flag. (But, if we
22621-
// do this, still need to handle `deletedTreeCleanUpLevel` correctly.)
22603+
var child = fiber.child; // TODO: Only traverse subtree if it has a PassiveStatic flag.
2262222604

2262322605
if (child !== null) {
2262422606
child.return = fiber;
@@ -22637,18 +22619,15 @@ function commitPassiveUnmountEffectsInsideOfDeletedTree_complete(
2263722619
while (nextEffect !== null) {
2263822620
var fiber = nextEffect;
2263922621
var sibling = fiber.sibling;
22640-
var returnFiber = fiber.return;
22622+
var returnFiber = fiber.return; // Recursively traverse the entire deleted tree and clean up fiber fields.
22623+
// This is more aggressive than ideal, and the long term goal is to only
22624+
// have to detach the deleted tree at the root.
2264122625

22642-
{
22643-
// Recursively traverse the entire deleted tree and clean up fiber fields.
22644-
// This is more aggressive than ideal, and the long term goal is to only
22645-
// have to detach the deleted tree at the root.
22646-
detachFiberAfterEffects(fiber);
22626+
detachFiberAfterEffects(fiber);
2264722627

22648-
if (fiber === deletedSubtreeRoot) {
22649-
nextEffect = null;
22650-
return;
22651-
}
22628+
if (fiber === deletedSubtreeRoot) {
22629+
nextEffect = null;
22630+
return;
2265222631
}
2265322632

2265422633
if (sibling !== null) {

0 commit comments

Comments
 (0)