GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [Experiment] Add feature flag for more aggressive memory clean-up of deleted fiber trees by bgirard · Pull Request #21039 · react/react

Conversation

@bgirard

@bgirard bgirard commented Mar 20, 2021

Copy link
Copy Markdown
Contributor

Summary

Add a new feature flag called 'enableStrongMemoryCleanup' that will recursively clean-up the FiberNode memory graph on unmount. This is to experiment on improving memory usage and/or reducing leaks after unmount.

Test Plan

Will run several memory usage scenario against this sync.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@facebook-github-bot facebook-github-bot added the CLA Signed label Mar 20, 2021
@bgirard
bgirard force-pushed the master branch from 9b4408f to ca237fc Compare March 20, 2021 00:13
@sizebot

sizebot commented Mar 20, 2021 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Comparing: 00d4f95...31e1977

Critical size changes

Includes critical production bundles, as well as any change greater than 2%:

Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable/react-dom/cjs/react-dom.production.min.js +0.10% 122.83 kB 122.96 kB +0.11% 39.52 kB 39.57 kB
oss-experimental/react-dom/cjs/react-dom.production.min.js +0.10% 129.33 kB 129.45 kB +0.06% 41.59 kB 41.61 kB
facebook-www/ReactDOM-prod.classic.js +0.47% 408.70 kB 410.61 kB +0.35% 75.80 kB 76.07 kB
facebook-www/ReactDOM-prod.modern.js +0.48% 396.96 kB 398.87 kB +0.36% 73.86 kB 74.13 kB
facebook-www/ReactDOMForked-prod.classic.js +0.47% 408.71 kB 410.62 kB +0.35% 75.80 kB 76.07 kB

Significant size changes

Includes any change greater than 0.2%:

Expand to show
Name +/- Base Current +/- gzip Base gzip Current gzip
facebook-www/ReactIs-dev.classic.js +0.74% 9.81 kB 9.89 kB +0.82% 2.67 kB 2.69 kB
facebook-www/ReactIs-dev.modern.js +0.72% 10.08 kB 10.15 kB +0.81% 2.72 kB 2.74 kB
facebook-www/SchedulerTracing-dev.modern.js +0.66% 11.11 kB 11.18 kB +0.98% 2.44 kB 2.47 kB
facebook-www/SchedulerTracing-dev.classic.js +0.66% 11.11 kB 11.18 kB +0.98% 2.44 kB 2.47 kB
facebook-www/ReactART-prod.modern.js +0.59% 257.12 kB 258.64 kB +0.50% 45.74 kB 45.98 kB
facebook-www/ReactART-prod.classic.js +0.58% 264.48 kB 266.01 kB +0.49% 46.98 kB 47.21 kB
facebook-www/ReactART-dev.modern.js +0.53% 695.64 kB 699.36 kB +0.73% 148.11 kB 149.19 kB
facebook-www/ReactART-dev.classic.js +0.53% 705.93 kB 709.65 kB +0.72% 150.22 kB 151.30 kB
facebook-www/ReactDOM-prod.modern.js +0.48% 396.96 kB 398.87 kB +0.36% 73.86 kB 74.13 kB
facebook-www/ReactDOMForked-prod.modern.js +0.48% 396.97 kB 398.88 kB +0.37% 73.87 kB 74.14 kB
facebook-www/ReactDOM-prod.classic.js +0.47% 408.70 kB 410.61 kB +0.35% 75.80 kB 76.07 kB
facebook-www/ReactDOMForked-prod.classic.js +0.47% 408.71 kB 410.62 kB +0.35% 75.80 kB 76.07 kB
facebook-www/ReactDOM-profiling.modern.js +0.46% 418.02 kB 419.93 kB +0.38% 77.48 kB 77.77 kB
facebook-www/ReactDOMForked-profiling.modern.js +0.46% 418.03 kB 419.94 kB +0.38% 77.49 kB 77.78 kB
facebook-www/ReactDOM-profiling.classic.js +0.44% 429.80 kB 431.71 kB +0.36% 79.34 kB 79.62 kB
facebook-www/ReactDOMForked-profiling.classic.js +0.44% 429.81 kB 431.72 kB +0.36% 79.33 kB 79.62 kB
facebook-www/ReactDOMForked-dev.modern.js +0.40% 1,034.99 kB 1,039.16 kB +0.52% 230.24 kB 231.43 kB
facebook-www/ReactDOM-dev.modern.js +0.40% 1,035.59 kB 1,039.76 kB +0.52% 230.26 kB 231.45 kB
facebook-www/ReactDOMForked-dev.classic.js +0.39% 1,061.23 kB 1,065.40 kB +0.50% 235.46 kB 236.64 kB
facebook-www/ReactDOM-dev.classic.js +0.39% 1,061.84 kB 1,066.01 kB +0.50% 235.49 kB 236.66 kB
oss-experimental/react-noop-renderer/cjs/react-noop-renderer.production.min.js +0.27% 13.17 kB 13.20 kB +0.24% 4.12 kB 4.13 kB
oss-stable/react-noop-renderer/cjs/react-noop-renderer.production.min.js +0.27% 13.17 kB 13.20 kB +0.24% 4.12 kB 4.13 kB
oss-experimental/react-noop-renderer/cjs/react-noop-renderer-persistent.production.min.js +0.27% 13.18 kB 13.22 kB +0.27% 4.13 kB 4.14 kB
oss-stable/react-noop-renderer/cjs/react-noop-renderer-persistent.production.min.js +0.27% 13.18 kB 13.22 kB +0.27% 4.13 kB 4.14 kB
facebook-react-native/react-test-renderer/cjs/ReactTestRenderer-prod.js +0.22% 241.18 kB 241.72 kB +0.19% 44.20 kB 44.29 kB
facebook-react-native/react-test-renderer/cjs/ReactTestRenderer-profiling.js +0.21% 253.98 kB 254.52 kB +0.16% 46.52 kB 46.59 kB
oss-stable/react-art/cjs/react-art.development.js +0.21% 597.81 kB 599.07 kB +0.28% 130.98 kB 131.34 kB
oss-stable/react-test-renderer/umd/react-test-renderer.development.js +0.21% 637.89 kB 639.21 kB +0.28% 134.92 kB 135.29 kB
oss-stable/react-test-renderer/cjs/react-test-renderer.development.js +0.21% 607.68 kB 608.94 kB +0.28% 133.33 kB 133.69 kB
facebook-react-native/react-test-renderer/cjs/ReactTestRenderer-dev.js +0.20% 618.98 kB 620.24 kB +0.28% 134.38 kB 134.75 kB
oss-stable/react-reconciler/cjs/react-reconciler.development.js +0.20% 654.03 kB 655.35 kB +0.28% 140.36 kB 140.75 kB
oss-experimental/react-test-renderer/umd/react-test-renderer.development.js +0.20% 654.74 kB 656.06 kB +0.27% 138.33 kB 138.71 kB
oss-experimental/react-test-renderer/cjs/react-test-renderer.development.js +0.20% 623.68 kB 624.94 kB +0.27% 136.71 kB 137.07 kB

Generated by 🚫 dangerJS against 31e1977

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bgirard
bgirard force-pushed the master branch from ca237fc to d9c532d Compare March 20, 2021 00:57
bvaughn
bvaughn reviewed Mar 20, 2021
View reviewed changes
Comment thread packages/react-reconciler/src/ReactFiberCommitWork.new.js Outdated
Comment on lines +1229 to +1233
if (fiber.stateNode) {
Object.keys(fiber.stateNode).forEach(key => {
if (key.indexOf('__react') === 0) {
delete fiber.stateNode[key];
}
});
}

@bvaughn bvaughn Mar 20, 2021

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels pretty heavy. Why is it needed given that we null out fiber.stateNode below (and we null out all expensive fiber fields)?

Even if something has a reference to the fiber at this point, it wouldn't have any deep references.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@bgirard bgirard Mar 20, 2021

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. We’re starting with the shotgun approach to confirm if this kills the leak. If not it doesn’t matter, we have to keep looking and narrow down what we miss.

When the leak is fixed then we can come back and find the right way to do this clean up.

I think you are correct. Worse case keeping a ref to an unmourned / detached DOM mode will be O(1) by retaining 1 and only 1 associated fiber node. Well sort this out once we confirm the leak is gone.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
gaearon
gaearon reviewed Mar 20, 2021
View reviewed changes
Comment thread packages/react-reconciler/src/ReactFiberCommitWork.new.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

gaearon
gaearon reviewed Mar 20, 2021
View reviewed changes
Comment thread packages/react-reconciler/src/ReactFiberCommitWork.new.js Outdated
if (fiber.stateNode) {
Object.keys(fiber.stateNode).forEach(key => {
if (key.indexOf('__react') === 0) {
delete fiber.stateNode[key];

@gaearon gaearon Mar 20, 2021

Copy link
Copy Markdown
Collaborator

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already know the exact names, don't we? Can we use them directly?

https://github.com/facebook/react/blob/6d3ecb70dceb225af0cd990b46d6c44b852c1d82/packages/react-dom/src/client/ReactDOMComponentTree.js#L39-L44

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

bgirard, bvaughn, and worstpractice reacted with thumbs up emoji
All reactions
  • 👍 3 reactions

@bgirard bgirard Mar 20, 2021

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added unmountNode to the HostConfig. Could use feedback if there's a better way.

Like I discussed with Brian this probably wont be necessary in the final version.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bgirard
bgirard force-pushed the master branch 2 times, most recently from 39b04e8 to 6cf1cf4 Compare March 20, 2021 21:54
@bgirard

bgirard commented Mar 21, 2021

Copy link
Copy Markdown
Contributor Author

This change and #21041 are related. I'm going to merge them into a React sync and test them with memlab to study the changes to leaks. We can then make final changes before landing these two and doing a production test.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bgirard

bgirard commented Mar 21, 2021 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

Here's a leak that memlab reports as fixed with this turned on (testing with #21041 on):

<SNIP UNRELATED INTERNAL CHAIN>
  --bindings (internal)--->  [(bound arguments)] (array) @646517 [16 bytes]
  --0 (internal)--->  [Detached FiberNode CometTransientDialogProvider] (object) @583545 [2.3KB]
  --child (property)--->  [Detached FiberNode react.provider] (object) @583439 [188 bytes]
  --child (property)--->  [Detached FiberNode] (object) @583059 [188 bytes]
  --child (property)--->  [Detached FiberNode react.provider] (object) @583043 [188 bytes]
  --child (property)--->  [Detached FiberNode CometLayout] (object) @582961 [188 bytes]
  --child (property)--->  [Detached FiberNode div] (object) @582841 [188 bytes]
  --child (property)--->  [Detached FiberNode div] (object) @582691 [188 bytes]
  --stateNode (property)--->  [Detached HTMLDivElement] (native) @109319 [48 bytes]
  --6 (element)--->  [Detached HTMLDivElement] (native) @109321 [228 bytes]
  --7 (element)--->  [Detached HTMLDivElement] (native) @109323 [5.7KB]
  --7 (element)--->  [Detached HTMLDivElement] (native) @108191 [580 bytes]
  --6 (element)--->  [Detached HTMLDivElement] (native) @108189 [332 bytes]
  --7 (element)--->  [Detached HTMLDivElement] (native) @108187 [7.8KB]
  --7 (element)--->  [Detached HTMLDivElement] (native) @108185 [160 bytes]
  --6 (element)--->  [Detached HTMLDivElement] (native) @1347749 [48 bytes]
  --6 (element)--->  [Detached HTMLDivElement] (native) @1347751 [48 bytes]
  --6 (element)--->  [Detached HTMLDivElement] (native) @1347753 [48 bytes]
  --6 (element)--->  [Detached HTMLDivElement] (native) @1347791 [48 bytes]
  --6 (element)--->  [Detached HTMLDivElement] (native) @1347793 [48 bytes]
  --6 (element)--->  [Detached HTMLDivElement] (native) @1347795 [48 bytes]
  --6 (element)--->  [Detached HTMLDivElement] (native) @1347801 [236 bytes]
  --6 (element)--->  [Detached HTMLDivElement] (native) @1348887 [140 bytes]
  --6 (element)--->  [Detached HTMLDivElement] (native) @1347567 [48 bytes]
  --6 (element)--->  [Detached HTMLDivElement] (native) @1347345 [48 bytes]
  --6 (element)--->  [Detached HTMLDivElement] (native) @1347347 [48 bytes]
  --7 (element)--->  [Detached HTMLDivElement] (native) @1347349 [48 bytes]
  --6 (element)--->  [Detached HTMLDivElement] (native) @1347351 [48 bytes]
  --7 (element)--->  [Detached HTMLDivElement] (native) @1347431 [48 bytes]
  --9 (element)--->  [Detached HTMLDivElement] (native) @1348185 [48 bytes]
  --6 (element)--->  [Detached HTMLDivElement] (native) @1348187 [48 bytes]
  --7 (element)--->  [Detached HTMLDivElement] (native) @1348189 [48 bytes]
  --__reactFiber$cq9ed31lytw (property)--->  [Detached FiberNode div] (object) @1720097 [1.4KB]
  --child (property)--->  [Detached FiberNode CometFeedMatchRenderer] (object) @1718217 [1.2KB]

We would need to dig deeper to confirm if this is just making a leak pointing to within a tree that detach. This is part hard to reason about from heap snapshots and memory tooling.

This appears to reduce memory leak in the create-life-event test case by double digit megabytes of memory usage.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@JacksonGL

JacksonGL commented Mar 22, 2021 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

MemLab observes a reduction of detached Fiber nodes on Facebook.
The cleanup may be very useful for further releasing memory retained by video caching.

Some examples:

Profile Page

Before Fix:

· fiber node size: 4.7MB
· regular fiber node size: 1.4MB
· detached fiber node size: *2MB*
· alternate fiber node size: 1.2MB

After Fix:

· fiber node size: 2.8MB
· regular fiber node size: 1.5MB
· detached fiber node size: *144.7KB*
· alternate fiber node size: 1.2MB

Home Tab

Before Fix:

· fiber node size: 3.8MB
· regular fiber node size: 2.2MB
· detached fiber node size: *3.6KB*
· alternate fiber node size: 1.6MB

After Fix:

· fiber node size: 3.8MB
· regular fiber node size: 2.2MB
· detached fiber node size: *2.7KB*
· alternate fiber node size: 1.6MB

Marketplace Tab

Before Fix:

· fiber node size: 3.1MB
· regular fiber node size: 2.3MB
· detached fiber node size: *3.2KB*
· alternate fiber node size: 972.5KB

After Fix:

· fiber node size: 3.1MB
· regular fiber node size: 2.3MB
· detached fiber node size: *1.9KB*
· alternate fiber node size: 966.7KB

Edit: More results before and after the change
(x-axis is navigation; y-axis is JS heap size)

before:
Screen Shot 2021-04-15 at 13 13 24

After:
Screen Shot 2021-04-15 at 13 13 35

bgirard, matthargett, electron-space, and bwhitty reacted with heart emoji
All reactions
  • ❤️ 4 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

acdlite
acdlite reviewed Mar 22, 2021
View reviewed changes
Comment thread packages/react-reconciler/src/ReactFiberCommitWork.old.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

@bgirard @acdlite
Add feature flag: enableStrongMemoryCleanup
82c7916
Add a feature flag that will test doing a recursive clean of an unmount
node. This will disconnect the fiber graph making leaks less severe.
@acdlite
acdlite force-pushed the master branch from 47761f1 to 7effaa2 Compare March 23, 2021 01:28
@acdlite
Detach sibling pointers in old child list
a16ac10
When a fiber is deleted, it's still part of the previous (alternate)
parent fiber's list of children. Because children are a linked list, an
earlier sibling that's still alive will be connected to the deleted
fiber via its alternate:


  live fiber
  --alternate--> previous live fiber
  --sibling--> deleted fiber

We can't disconnect `alternate` on nodes that haven't been deleted
yet, but we can disconnect the `sibling` and `child` pointers.

Will use this feature flag to test the memory impact.
@acdlite
acdlite force-pushed the master branch 3 times, most recently from f081a4b to a16ac10 Compare March 23, 2021 01:31
@acdlite
Combine into single enum flag
100239e
I combined `enableStrongMemoryCleanup` and `enableDetachOldChildList`
into a single enum flag. The flag has three possible values. Each level
is a superset of the previous one and performs more aggressive clean up.

We will use this to compare the memory impact of each level.
@acdlite acdlite changed the title [Draft] Add feature flag: enableStrongMemoryCleanup [Experiment] Add feature flag for more aggressive memory clean-up of deleted fiber trees Mar 23, 2021
@acdlite
acdlite force-pushed the master branch from 3677bb7 to 100239e Compare March 23, 2021 03:50
@acdlite
Add Flow type to new host config method
f73ae7e
@acdlite
acdlite force-pushed the master branch from 10ff979 to f73ae7e Compare March 23, 2021 04:11
@acdlite
Re-use existing recursive clean up path
31e1977
We already have a recursive loop that visits every deleted fiber. We
can re-use that one for clean up instead of adding another one.
@acdlite
acdlite merged commit 25bfa28 into react:master Mar 23, 2021
@acdlite acdlite mentioned this pull request Mar 23, 2021
Detach sibling pointers in old child list #21041
Closed
facebook-github-bot pushed a commit to react/react-native that referenced this pull request Apr 6, 2021
@kacieb @facebook-github-bot
React Native sync for revisions 6d3ecb7...c9aab1c
2785ce7
Summary:
This sync includes the following changes:
- **[c9aab1c](react/react@c9aab1c9d )**: [email protected] //<Dan Abramov>//
- **[516b76b](react/react@516b76b9a )**: [Fast Refresh] Support callthrough HOCs ([#21104](react/react#21104)) //<Dan Abramov>//
- **[0853aab](react/react@0853aab74 )**: Log all errors to console.error by default ([#21130](react/react#21130)) //<Sebastian Markbåge>//
- **[d1294c9](react/react@d1294c9d4 )**: Add global onError handler ([#21129](react/react#21129)) //<Sebastian Markbåge>//
- **[64983aa](react/react@64983aab5 )**: Remove redundant setUpdatePriority call ([#21127](react/react#21127)) //<Andrew Clark>//
- **[634cc52](react/react@634cc52e6 )**: Delete dead variable: currentEventWipLanes ([#21123](react/react#21123)) //<Andrew Clark>//
- **[1102224](react/react@1102224bb )**: Fix: flushSync changes priority inside effect ([#21122](react/react#21122)) //<Andrew Clark>//
- **[dbe98a5](react/react@dbe98a5aa )**: Move sync task queue to its own module ([#21109](react/react#21109)) //<Andrew Clark>//
- **[3ba5c87](react/react@3ba5c8737 )**: Remove Scheduler indirection ([#21107](react/react#21107)) //<Andrew Clark>//
- **[46b68ea](react/react@46b68eaf6 )**: Delete LanePriority type ([#21090](react/react#21090)) //<Andrew Clark>//
- **[dcd1304](react/react@dcd13045e )**: Use Lane to track root callback priority ([#21089](react/react#21089)) //<Andrew Clark>//
- **[5f21a9f](react/react@5f21a9fca )**: Clean up host pointers in level 2 of clean-up flag ([#21112](react/react#21112)) //<Andrew Clark>//
- **[32d6f39](react/react@32d6f39ed )**: [Fizz] Support special HTML/SVG/MathML tags to suspend ([#21113](react/react#21113)) //<Sebastian Markbåge>//
- **[a77dd13](react/react@a77dd13ed )**: Delete enableDiscreteEventFlushingChange ([#21110](react/react#21110)) //<Andrew Clark>//
- **[048ee4c](react/react@048ee4c0c )**: Use `act` in fuzz tester to flush expired work ([#21108](react/react#21108)) //<Andrew Clark>//
- **[556644e](react/react@556644e23 )**: Fix plurals ([#21106](react/react#21106)) //<Sebastian Markbåge>//
- **[8b74143](react/react@8b741437b )**: Rename SuspendedWork to Task ([#21105](react/react#21105)) //<Sebastian Markbåge>//
- **[38a1aed](react/react@38a1aedb4 )**: [Fizz] Add FormatContext and Refactor Work ([#21103](react/react#21103)) //<Sebastian Markbåge>//
- **[1b7e471](react/react@1b7e471b9 )**: React Native New Architecture: Support passing nativeViewTag to getInspectorDataForViewAtPoint callback, for React DevTools compat ([#21080](react/react#21080)) //<Joshua Gross>//
- **[4a99c5c](react/react@4a99c5c3a )**: Use highest priority lane to detect interruptions ([#21088](react/react#21088)) //<Andrew Clark>//
- **[77be527](react/react@77be52729 )**: Remove LanePriority from computeExpirationTime ([#21087](react/react#21087)) //<Andrew Clark>//
- **[3221e8f](react/react@3221e8fba )**: Remove LanePriority from getBumpedLaneForHydration ([#21086](react/react#21086)) //<Andrew Clark>//
- **[05ec0d7](react/react@05ec0d764 )**: Entangled expired lanes with SyncLane ([#21083](react/react#21083)) //<Andrew Clark>//
- **[03ede83](react/react@03ede83d2 )**: Use EventPriority to track update priority ([#21082](react/react#21082)) //<Andrew Clark>//
- **[a63f095](react/react@a63f0953b )**: Delete SyncBatchedLane ([#21061](react/react#21061)) //<Ricky>//
- **[fa868d6](react/react@fa868d6be )**: Make opaque EventPriority type a Lane internally ([#21065](react/react#21065)) //<Andrew Clark>//
- **[eb58c39](react/react@eb58c3909 )**: react-hooks/exhaustive-deps: Handle optional chained methods as dependency ([#20204](react/react#20204)) ([#20247](react/react#20247)) //<Ari Perkkiö>//
- **[7b84dbd](react/react@7b84dbd16 )**: Fail build on deep requires in npm packages ([#21063](react/react#21063)) //<Dan Abramov>//
- **[2c9d8ef](react/react@2c9d8efc8 )**: Add react-reconciler/constants entry point ([#21062](react/react#21062)) //<Dan Abramov>//
- **[d0eaf78](react/react@d0eaf7829 )**: Move priorities to separate import to break cycle ([#21060](react/react#21060)) //<Andrew Clark>//
- **[435cff9](react/react@435cff986 )**: [Fizz] Expose callbacks in options for when various stages of the content is done ([#21056](react/react#21056)) //<Sebastian Markbåge>//
- **[25bfa28](react/react@25bfa287f )**: [Experiment] Add feature flag for more aggressive memory clean-up of deleted fiber trees ([#21039](react/react#21039)) //<Benoit Girard>//
- **[8fe7810](react/react@8fe7810e7 )**: Remove already completed comment ([#21054](react/react#21054)) //<Sebastian Markbåge>//
- **[6c3202b](react/react@6c3202b1e )**: [Fizz] Use identifierPrefix to avoid conflicts within the same response ([#21037](react/react#21037)) //<Sebastian Markbåge>//
- **[dcdf8de](react/react@dcdf8de7e )**: Remove discrete lanes and priorities ([#21040](react/react#21040)) //<Andrew Clark>//
- **[ca99ae9](react/react@ca99ae97b )**: Replace some flushExpired callsites ([#20975](react/react#20975)) //<Ricky>//
- **[1fafac0](react/react@1fafac002 )**: Use SyncLane for discrete event hydration ([#21038](react/react#21038)) //<Andrew Clark>//

Changelog:
[General][Changed] - React Native sync for revisions 6d3ecb7...c9aab1c

jest_e2e[run_all_tests]

Reviewed By: JoshuaGross

Differential Revision: D27436763

fbshipit-source-id: da79a41e26bffdcdacd293178062edf098e9b58a
koto pushed a commit to koto/react that referenced this pull request Jun 15, 2021
@bgirard @acdlite @koto
[Experiment] Add feature flag for more aggressive memory clean-up of …
391b419
…deleted fiber trees (react#21039)

* Add feature flag: enableStrongMemoryCleanup

Add a feature flag that will test doing a recursive clean of an unmount
node. This will disconnect the fiber graph making leaks less severe.

* Detach sibling pointers in old child list

When a fiber is deleted, it's still part of the previous (alternate)
parent fiber's list of children. Because children are a linked list, an
earlier sibling that's still alive will be connected to the deleted
fiber via its alternate:


  live fiber
  --alternate--> previous live fiber
  --sibling--> deleted fiber

We can't disconnect `alternate` on nodes that haven't been deleted
yet, but we can disconnect the `sibling` and `child` pointers.

Will use this feature flag to test the memory impact.

* Combine into single enum flag

I combined `enableStrongMemoryCleanup` and `enableDetachOldChildList`
into a single enum flag. The flag has three possible values. Each level
is a superset of the previous one and performs more aggressive clean up.

We will use this to compare the memory impact of each level.

* Add Flow type to new host config method

* Re-use existing recursive clean up path

We already have a recursive loop that visits every deleted fiber. We
can re-use that one for clean up instead of adding another one.

Co-authored-by: Andrew Clark <[email protected]>
threepointone pushed a commit to threepointone/react that referenced this pull request Oct 24, 2021
@bgirard @acdlite @threepointone
[Experiment] Add feature flag for more aggressive memory clean-up of …
5270ef3
…deleted fiber trees (react#21039)

* Add feature flag: enableStrongMemoryCleanup

Add a feature flag that will test doing a recursive clean of an unmount
node. This will disconnect the fiber graph making leaks less severe.

* Detach sibling pointers in old child list

When a fiber is deleted, it's still part of the previous (alternate)
parent fiber's list of children. Because children are a linked list, an
earlier sibling that's still alive will be connected to the deleted
fiber via its alternate:


  live fiber
  --alternate--> previous live fiber
  --sibling--> deleted fiber

We can't disconnect `alternate` on nodes that haven't been deleted
yet, but we can disconnect the `sibling` and `child` pointers.

Will use this feature flag to test the memory impact.

* Combine into single enum flag

I combined `enableStrongMemoryCleanup` and `enableDetachOldChildList`
into a single enum flag. The flag has three possible values. Each level
is a superset of the previous one and performs more aggressive clean up.

We will use this to compare the memory impact of each level.

* Add Flow type to new host config method

* Re-use existing recursive clean up path

We already have a recursive loop that visits every deleted fiber. We
can re-use that one for clean up instead of adding another one.

Co-authored-by: Andrew Clark <[email protected]>
threepointone pushed a commit to threepointone/react that referenced this pull request Oct 24, 2021
@bgirard @acdlite @threepointone
[Experiment] Add feature flag for more aggressive memory clean-up of …
cf25bf9
…deleted fiber trees (react#21039)

* Add feature flag: enableStrongMemoryCleanup

Add a feature flag that will test doing a recursive clean of an unmount
node. This will disconnect the fiber graph making leaks less severe.

* Detach sibling pointers in old child list

When a fiber is deleted, it's still part of the previous (alternate)
parent fiber's list of children. Because children are a linked list, an
earlier sibling that's still alive will be connected to the deleted
fiber via its alternate:


  live fiber
  --alternate--> previous live fiber
  --sibling--> deleted fiber

We can't disconnect `alternate` on nodes that haven't been deleted
yet, but we can disconnect the `sibling` and `child` pointers.

Will use this feature flag to test the memory impact.

* Combine into single enum flag

I combined `enableStrongMemoryCleanup` and `enableDetachOldChildList`
into a single enum flag. The flag has three possible values. Each level
is a superset of the previous one and performs more aggressive clean up.

We will use this to compare the memory impact of each level.

* Add Flow type to new host config method

* Re-use existing recursive clean up path

We already have a recursive loop that visits every deleted fiber. We
can re-use that one for clean up instead of adding another one.

Co-authored-by: Andrew Clark <[email protected]>
@gaearon gaearon mentioned this pull request Mar 29, 2022
Add React 18 changelog #24195
Merged
@banderson banderson mentioned this pull request Feb 11, 2023
fix: Add missing React 18 reconciler function Shopify/remote-dom#206
Merged
ghesst-rbx Bot pushed a commit to Roblox/react-luau that referenced this pull request Feb 21, 2026
@Nicell
UIBLOX-4139: Memory experiment upstream #flagged (#454)
4588574
Implements react/react#21039 on our codebase.
Creates a new deleted tree clean up level with three distinct levels.
Facebook did an experiment and found level 3 to be the best, we should
do the same and see whether the existing path, 1, 2, or 3 is the best.
ghesst-rbx Bot pushed a commit to Roblox/react-luau that referenced this pull request Apr 24, 2026
@Nicell
UIBLOX-4139: Memory experiment upstream #flagged (#454)
5f2c30f
Implements react/react#21039 on our codebase.
Creates a new deleted tree clean up level with three distinct levels.
Facebook did an experiment and found level 3 to be the best, we should
do the same and see whether the existing path, 1, 2, or 3 is the best.
mrizwanashiq pushed a commit to mrizwanashiq/react that referenced this pull request Jun 25, 2026
@bgirard @acdlite
[Experiment] Add feature flag for more aggressive memory clean-up of …
709010a
…deleted fiber trees (react#21039)

* Add feature flag: enableStrongMemoryCleanup

Add a feature flag that will test doing a recursive clean of an unmount
node. This will disconnect the fiber graph making leaks less severe.

* Detach sibling pointers in old child list

When a fiber is deleted, it's still part of the previous (alternate)
parent fiber's list of children. Because children are a linked list, an
earlier sibling that's still alive will be connected to the deleted
fiber via its alternate:


  live fiber
  --alternate--> previous live fiber
  --sibling--> deleted fiber

We can't disconnect `alternate` on nodes that haven't been deleted
yet, but we can disconnect the `sibling` and `child` pointers.

Will use this feature flag to test the memory impact.

* Combine into single enum flag

I combined `enableStrongMemoryCleanup` and `enableDetachOldChildList`
into a single enum flag. The flag has three possible values. Each level
is a superset of the previous one and performs more aggressive clean up.

We will use this to compare the memory impact of each level.

* Add Flow type to new host config method

* Re-use existing recursive clean up path

We already have a recursive loop that visits every deleted fiber. We
can re-use that one for clean up instead of adding another one.

Co-authored-by: Andrew Clark <[email protected]>
ghesst-rbx Bot pushed a commit to Roblox/react-luau that referenced this pull request Jul 1, 2026
@Nicell
UIBLOX-4139: Memory experiment upstream #flagged (#454)
71a3123
Implements react/react#21039 on our codebase.
Creates a new deleted tree clean up level with three distinct levels.
Facebook did an experiment and found level 3 to be the best, we should
do the same and see whether the existing path, 1, 2, or 3 is the best.
ghesst-rbx Bot pushed a commit to Roblox/react-luau that referenced this pull request Sep 2, 2026
@Nicell
UIBLOX-4139: Memory experiment upstream #flagged (#454)
2df4458
Implements react/react#21039 on our codebase.
Creates a new deleted tree clean up level with three distinct levels.
Facebook did an experiment and found level 3 to be the best, we should
do the same and see whether the existing path, 1, 2, or 3 is the best.
hanzo-dev pushed a commit to hanzoai/react that referenced this pull request Sep 9, 2026
@bgirard @acdlite
[Experiment] Add feature flag for more aggressive memory clean-up of …
3c15bbc
…deleted fiber trees (react#21039)

* Add feature flag: enableStrongMemoryCleanup

Add a feature flag that will test doing a recursive clean of an unmount
node. This will disconnect the fiber graph making leaks less severe.

* Detach sibling pointers in old child list

When a fiber is deleted, it's still part of the previous (alternate)
parent fiber's list of children. Because children are a linked list, an
earlier sibling that's still alive will be connected to the deleted
fiber via its alternate:


  live fiber
  --alternate--> previous live fiber
  --sibling--> deleted fiber

We can't disconnect `alternate` on nodes that haven't been deleted
yet, but we can disconnect the `sibling` and `child` pointers.

Will use this feature flag to test the memory impact.

* Combine into single enum flag

I combined `enableStrongMemoryCleanup` and `enableDetachOldChildList`
into a single enum flag. The flag has three possible values. Each level
is a superset of the previous one and performs more aggressive clean up.

We will use this to compare the memory impact of each level.

* Add Flow type to new host config method

* Re-use existing recursive clean up path

We already have a recursive loop that visits every deleted fiber. We
can re-use that one for clean up instead of adding another one.

Co-authored-by: Andrew Clark <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@gaearon gaearon gaearon left review comments
@acdlite acdlite acdlite left review comments
+1 more reviewer
@bvaughn bvaughn bvaughn left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

CLA Signed

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

7 participants

@bgirard @sizebot @JacksonGL @bvaughn @gaearon @acdlite @facebook-github-bot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.